- 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 =
推薦閱讀
- Java入門很輕松(微課超值版)
- Visual C#.NET程序設計
- R Data Analysis Cookbook(Second Edition)
- 程序設計基礎教程:C語言
- PLC應用技術(三菱FX2N系列)
- Java網絡編程核心技術詳解(視頻微課版)
- Unity 2017 Mobile Game Development
- C#開發案例精粹
- Babylon.js Essentials
- C語言程序設計
- Android驅動開發權威指南
- 移動增值應用開發技術導論
- Hands-On JavaScript for Python Developers
- Python機器學習算法與應用
- JavaScript程序設計:基礎·PHP·XML