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?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.