- 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 =
推薦閱讀
- 新手學Visual C# 2008程序設計
- PHP+MySQL網站開發項目式教程
- 程序設計基礎教程:C語言
- Mobile Device Exploitation Cookbook
- 從零學Java設計模式
- Qt 4開發實踐
- 快樂編程:青少年思維訓練
- PHP動態網站開發實踐教程
- Flutter之旅
- Practical Time Series Analysis
- HTML+CSS+JavaScript前端開發(慕課版)
- React.js 16從入門到實戰
- 編程改變生活:用PySide6/PyQt6創建GUI程序(進階篇·微課視頻版)
- 智能優化算法與MATLAB編程實踐
- 微信小程序開發實戰教程(PHP+Laravel+MySQL)(微課版)