Calling a method without object or its class name..
-
hi.. i'm writing a utility package for my tool.. i want a method to be used globally that can be called with out object or its class name.. is it possible. plz help me.. regards, nas
-
A public static class with public static methods is probably as close as you can get. Then you can just use Class.DoMethod() from anywhere where the class is available (same project or it's in a reference, don't forget using directive)
namespace Globality { public static class GlobalClass { public static void MyMethod() { } } }
and then somewhere elseusing Globality GlobalClass.MyMethod();
Visual Studio can't evaluate this, can you?
public object moo { __get { return moo; } __set { moo = value; } }
-
hi.. i'm writing a utility package for my tool.. i want a method to be used globally that can be called with out object or its class name.. is it possible. plz help me.. regards, nas
you could have a public static delegate declared in your app and then assign it when the object containing the method you want to call is instantiated. Russell