简体   繁体   English

这两个委托声明有什么区别?

[英]What is the difference between these two delegate statements?

I'm looking at delegates for the first time and wondered what the differnce is between these two styles. 我是第一次看代表,并想知道这两种风格之间的差异。

OfferList.NextPage += delegate(int page)
{
    OnNextPage(page);
};


void OnNextPage(int page)
{
    ...
}

and

Toolbar.OfferBookmarkRemoved += new OfferBookmarkRemoved(OnOfferBookmarkRemoved);

void OnOfferBookmarkRemoved(int offerId)
{
    ...
}

Thanks in advance. 提前致谢。

The first one is an Anonymous Method , and the second is a Name Method. 第一个是匿名方法 ,第二个是名称方法。

See also Delegates with Named vs. Anonymous Methods (C# Programming Guide) 另请参见具有命名与匿名方法的代理(C#编程指南)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM