官术网_书友最值得收藏!

Constructing a delegate

First, in order to make the delegate, above the line beginning with public partial class..., enter the following:

public delegate void Summarize<T>(T x, T y);

Here, public means accessible anywhere, delegate is a keyword, and void doesn't return a value. The delegate name is Summarize, and it can act on different data types because T is present and not integer, double, or something like that. T is a generic.

Now remember, delegates serve essentially as function wrappers. Correct? You use them to point to multiple functions, so you can cascade function calls, for example. The same principle holds here. So, for example, to make use of this, enter the following between a set of curly braces under the line beginning with protected void Button1_Click...:

Summarize<double> s =
主站蜘蛛池模板: 申扎县| 公主岭市| 谢通门县| 新沂市| 兰溪市| 庐江县| 鄂尔多斯市| 巴东县| 开鲁县| 吐鲁番市| 阿合奇县| 新安县| 翼城县| 铜鼓县| 泗阳县| 山东省| 子洲县| 吉林省| 建瓯市| 宜丰县| 莱州市| 水城县| 甘南县| 迭部县| 汉源县| 周口市| 和静县| 苍山县| 宜章县| 凌云县| 白玉县| 上虞市| 太康县| 嘉黎县| 光山县| 常宁市| 双鸭山市| 沐川县| 如东县| 长武县| 重庆市|