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

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 =
主站蜘蛛池模板: 延寿县| 西城区| 盐山县| 林周县| 涞水县| 塔河县| 江阴市| 淳安县| 龙江县| 得荣县| 光山县| 阳谷县| 喀喇沁旗| 江都市| 津南区| 石泉县| 长葛市| 邳州市| 合山市| 青田县| 唐山市| 阿鲁科尔沁旗| 和平区| 尉氏县| 沂水县| 镇原县| 磐安县| 绵竹市| 麦盖提县| 淳安县| 饶河县| 庄河市| 晋城| 邵东县| 乐都县| 衢州市| 东海县| 安庆市| 江山市| 泸州市| 梁河县|