Can anyone tell me how to declare a global function in c#, similar to what a Module does in VB.net?
I need to call a function that can be called in my form1, fo
You can create a static class (even enclose it in it's own namespace so as not to pollute the main project namespace), then call it from anywhere:
namespace SomeNamespace
{
public static class SomeClass
{
public static string SomeMethod()
{
...
}
}
}
Then, in your code, you can call it using:
string x = SomeNamespace.SomeClass.SomeMethod();
Or, you can set up a using at the top of the code and just reference it without the namespace:
using SomeNamespace;
...
string x = SomeClass.SomeMethod();