- 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 =
推薦閱讀
- Advanced Splunk
- Python程序設計教程(第2版)
- The DevOps 2.3 Toolkit
- Learn to Create WordPress Themes by Building 5 Projects
- PHP+MySQL網站開發項目式教程
- Terraform:多云、混合云環境下實現基礎設施即代碼(第2版)
- 執劍而舞:用代碼創作藝術
- PLC應用技術(三菱FX2N系列)
- Building Machine Learning Systems with Python(Second Edition)
- Canvas Cookbook
- 現代C:概念剖析和編程實踐
- SSH框架企業級應用實戰
- Python編程快速上手2
- SQL Server on Linux
- 優化驅動的設計方法