Delegating A Namespace  
Author Message

PostPosted: Visual C# Language, Delegating A Namespace Top

Can you reference a namspace.class.method using some sort of delegate or enumerator e.g.

instead of namespace1.class1.method


Where your referencing a static method in another namespace.

Visual C#10  

PostPosted: Visual C# Language, Delegating A Namespace Top

Sort of (if this answers your question).

You can use the using directive.

using obj1 = namespace1.class1;

then you can call


Or if you mean an actual indirection you can create a delegate with the same prototype as the method -

public delegate void method1delegate();

Then create an instance of the delegate -

public class Test {

method1delegate myMethod1Delegate;


Then you can instantiate it as such -

myMethod1Delegate = new method1delegate(namespace1.class1.method1)

And you can call your function by -


Sorry if this isn't the cleanest example, but basically what you would use is the using directive or a delegate.