C#.NET delegate keyword as name of the function to be called using delegate object/constructor

北城以北 提交于 2019-12-01 12:01:22

If I understand your question correctly, you're confused with use of the keyword delegate at different places.

public delegate void AppendChildData(T entityAggregate, object childEntityKeyValue);

The sort answer for the delegate in the above is

A delegate is a type that defines a method signature. When you instantiate a delegate, you can associate its instance with any method with a compatible signature. You can invoke (or call) the method through the delegate instance. You can find more on MSDN

In the second case like below

protected override void BuildChildCallbacks()
  {
   this.childCallbacks.Add("allowances", delegate(Project project, object childKeyName) 
        { 
              this.AppendProjectAllowances(project); 
        });
  }

delegate is used to declare anonymous method. In one sentence, it is method without name. More description is here MSDN

And last but not least, in future you should be more specific about your questions. :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!