Action,Func,Predicate 这三种委托类型可以转换为Delegate类型吗? RRS feed


  • 他们的本质都是委托,当然可以。

     Action act = new Action(() => { Console.WriteLine("我是Action"); });
                Func<int> func = () => { Console.WriteLine("我是Func"); return 1; };
                Predicate<string> pred = (s=> { Console.WriteLine("我是Pred"); return true; };
                Delegate d = act;
                d = func;
                d = pred;

    If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer

    Help by clicking:
    Click here to donate your rice to the poor
    Click to Donate
    Click to feed Dogs & Cats

    Found any spamming-senders? Please report at: Spam Report

    • 已标记为答案 GuanEr 2013年5月25日 6:08
    2013年5月24日 9:24