Question on dictionary of delegates
I am writing an if/else alternative using a table driven method.
I have the following code:
var map = new[]
{
new
{
Predica开发者_JAVA百科te = new Func<Type, bool>(type => type.IsInterface),
Selector = new Func<Type, Delegate>(str, sww.Invoke())
}
};
In the selector, I want to return a delagate which I can invoke (points to another method), or specify in line (eg (delegate() { // Do something here. }
).
I am using (and modifying) the code from here: Table Driven Method issue
How can I do this?
Instead of Delegate, you can use a specific delegate type, such as Action:
Selector = new Func<Type, Action>(str, sww.Invoke)
精彩评论