Delegate Problem
-
I am creating a console sort of like quakes in which the user can modify variables and execute commands by typing them into a command line. So I have a Shell class which keeps track of variables and commands that are registered to it. Each command that can be executed has a delegate to the function that it calls when the user types its name in. I want to know if its possible to pass a function name as an arguement to another function, the purpose being that the Shell class would take care of creating the actual delegate. I noticed that in the delegate constructor it uses the parameter void() target, but when i try that it generates a bunch of errors. Any help would be appreciated. Thank you. Steve Not all who wander are lost...
-
I am creating a console sort of like quakes in which the user can modify variables and execute commands by typing them into a command line. So I have a Shell class which keeps track of variables and commands that are registered to it. Each command that can be executed has a delegate to the function that it calls when the user types its name in. I want to know if its possible to pass a function name as an arguement to another function, the purpose being that the Shell class would take care of creating the actual delegate. I noticed that in the delegate constructor it uses the parameter void() target, but when i try that it generates a bunch of errors. Any help would be appreciated. Thank you. Steve Not all who wander are lost...
You'll have to wait for .NET ver2 for anonymous delegates, in the meantime you will have to template each of them, or maybe you can use Reflection.Emit to build delegates dynamically, but that a bit difficult. another suggestion is to go the COntrol.Invoke way, not sure if you can define a delegate with a "params" parameter. Hey leppie! Your "proof" seems brilliant and absurd at the same time. - Vikram Punathambekar 28 Apr '03