Please Explain .NET Delegates

前端 未结 9 1195
离开以前
离开以前 2020-12-30 07:40

So I read MSDN and Stack Overflow. I understand what the Action Delegate does in general but it is not clicking no matter how many examples I do. In general, the same goes f

9条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-30 08:28

    You would pass it a void method that takes an IEnumerable and an Exception as parameters...

    Say you have this method:

    public void DoSomeStuffWithCustomers(
      IEnumerable customers, Exception exception)
    {     
    }
    

    You would call the GetCustomers method like this:

    GetCustomers(DoSomeStuffWithCustomers);
    

提交回复
热议问题