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

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 =
主站蜘蛛池模板: 安西县| 英山县| 新巴尔虎左旗| 井陉县| 新乐市| 青州市| 聂荣县| 商洛市| 定安县| 鱼台县| 巴林左旗| 昌都县| 建平县| 龙门县| 景谷| 洛阳市| 江口县| 四平市| 新乡县| 林芝县| 湛江市| 米脂县| 上杭县| 湄潭县| 南部县| 姚安县| 阿拉尔市| 唐海县| 肇源县| 驻马店市| 鄢陵县| 金寨县| 赣榆县| 正镶白旗| 油尖旺区| 霍邱县| 关岭| 文山县| 沙坪坝区| 大悟县| 德化县|