S
Stephen Johns
I want to have a Hashtable whose keys are strings and whose values are
delegates.
Well, ok, I have that:
dels = new Hastable();
dels.Add( "key", new Foo1Delegate(MyFoo1) );
dels.Add( "key", new Foo2Delegate(MyFoo2) );
dels.Add( "key", new Foo3Delegate(MyFoo3) );
This works.
BUT! I can't get the darned things back out!
I want to do:
delegate d = (delegate)dels["key"];
d( arg );
The first line results in a syntax error.
MyFoo1 f = (MyFoo1)dels["key"];
f( arg );
works, but I have to know the delegate type to get it out - negating
what I am trying to accomplish.
All the methods I will call have the same arguments.
Basically looking for C/Function-Pointer kind of thing.
Anyone know how to do this in C#?
Any help greatly appreciated.
delegates.
Well, ok, I have that:
dels = new Hastable();
dels.Add( "key", new Foo1Delegate(MyFoo1) );
dels.Add( "key", new Foo2Delegate(MyFoo2) );
dels.Add( "key", new Foo3Delegate(MyFoo3) );
This works.
BUT! I can't get the darned things back out!
I want to do:
delegate d = (delegate)dels["key"];
d( arg );
The first line results in a syntax error.
MyFoo1 f = (MyFoo1)dels["key"];
f( arg );
works, but I have to know the delegate type to get it out - negating
what I am trying to accomplish.
All the methods I will call have the same arguments.
Basically looking for C/Function-Pointer kind of thing.
Anyone know how to do this in C#?
Any help greatly appreciated.