What is the best way to convert Action to Func?

后端 未结 2 445
清酒与你
清酒与你 2020-12-20 11:05

I have two functions in my class with this signatures,

public static TResult Execute(Func remoteCall);
public static void Exe         


        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-20 11:43

    Wrap it in a delegate of type Func with a dummy return value, e.g.

    public static void Execute(Action remoteCall)
    {
        Execute(t => { remoteCall(t); return true; });
    }
    

提交回复
热议问题