开发者

Question on dictionary of delegates

开发者 https://www.devze.com 2022-12-23 13:10 出处:网络
I am writing an if/else alternative using a table driven method. I have the following code: var map = new[]

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

精彩评论

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