0

Hi,
Hopefully my question has a simple answer. I am working on a project with a fairly large amount of functions and global variables. What I want to be able to do is put many of those functions into other files so that the main file is shorter and easier to read. The only way that I know how to do this is to create classes with the functions in them and then load the functions/methods into the main program using objects. However, if I did this I assume I'd have to add a long list of parameters for each 'method' now. Is there another way to organize the functions without all the parameters?

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by jonsca
0

It might work if you use the partial keyword.

In the first file:

namespace DaniWeb
{
   public partial class MyClass
   {
        public int Method1()
        {

        }
    }
}

In another file:

namespace DaniWeb
{
   public partial class MyClass
   {
        public void Method2()
        {

        }
    }
}

Otherwise like you said, you'd have to pass in a bunch of other variables to have access. It might make sense if you had a second (separate) class to pass the Form1 object into it to have access to all of its elements but beyond that it could get complicated.

Edited by jonsca: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.