- Beginning C# 7 Hands-On:Advanced Language Features
- Tom Owsiak
- 130字
- 2021-07-02 15:29:20
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 =
推薦閱讀
- 基于粒計算模型的圖像處理
- 解構產品經理:互聯網產品策劃入門寶典
- CentOS 7 Linux Server Cookbook(Second Edition)
- x86匯編語言:從實模式到保護模式(第2版)
- 從0到1:HTML+CSS快速上手
- Essential Angular
- Create React App 2 Quick Start Guide
- Unity 2018 Augmented Reality Projects
- Arduino機器人系統設計及開發
- SQL Server 2008實用教程(第3版)
- 軟件設計模式(Java版)
- C語言從入門到精通(微視頻精編版)
- 編寫高質量代碼之Java(套裝共2冊)
- Learning Ext JS(Fourth Edition)
- 測試基地實訓指導