Convert this delegate to an anonymous method or lambda

后端 未结 4 962
忘掉有多难
忘掉有多难 2020-12-28 16:01

I am new to all the anonymous features and need some help. I have gotten the following to work:

public void FakeSaveWithMessage(Transaction t)
{
    t.Messa         


        
4条回答
  •  自闭症患者
    2020-12-28 16:51

    What Mark said.

    The problem is that Do takes a Delegate parameter. The compiler can't convert the anonymous methods to Delegate, only a "delegate type" i.e. a concrete type derived from Delegate.

    If that Do function had took Action<>, Action<,> ... etc. overloads, you wouldn't need the cast.

提交回复
热议问题