Is there any performance difference between having all of my static methods inside the main `Form` class, or having them separated out into their own class?

public partial class MyForm : Form { public MyForm() { Method1(); Method2(); Method3(); //or OtherClass.Method1(); OtherClass.Method2(); OtherClass.Method3(); } public static void Method1(object obj1, object obj2, ...) { //do stuff } public static void Method2() { //do stuff } public static void Method3() { //do stuff } } public static class OtherClass { public static void Method1(object obj1, object obj2, ...) { //do stuff } public static void Method2() { //do stuff } public static void Method3() { //do stuff } }

And I would assume that if a method has nothing to do with the class that its in, it really should be moved into its own class, yea?

CocoaMix86's user avatar

5

No there is no difference (at least noticeable one).

And I would assume that if a method has nothing to do with the class that its in, it really should be moved into its own class, yea?

Yes, that is one of the main goals of the class abstraction present in a language - to achieve modularity.

Note that if you really want you can use the using static OtherClass which will allow to call it's static methods without "prefixing" them with the class name (though usually I prefer the explicit class name):

using static SomeNamespace.OuterClass; public partial class MyForm : Form { public MyForm() { Method1(); // ... } }

Guru Stron's user avatar

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.