开发者

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜