Standard delegates in C#(C# 中的标准委托)
问题描述
在 C# 中预定义了一些委托
There are some Delegates predefined in C#
我知道这些:
EventHandler // Default event callbacks
EventHandler<T> // Default event callbacks with custom parameter (inheriting from EventArgs)
Action // Function without return value and without parameter
Action<T1, T2, T3, T4> // Function without return value and 1-4 parameters
Func<T1, T2, T3, T4, TResult> // Methos with 0-4 parameters and one result type
Predicate<T> // equivalent to Func<T, bool>
对于特殊情况和框架的生成表单部分还有很多,但这些通常很适合用于自行编写的代码.
There are many more for special cases and generated form parts of the framework, but these are often good to use in self written code.
如果你知道一些更有用的添加它们.否则,这是回答.
If you know some more useful add them. Otherwise this is answered.
推荐答案
它们没有在 C# 中预定义.它们由框架定义.
They're not predefined in C#. They're defined by the framework.
Action 和 Func 委托系列比您所展示的要宽 - 它们上升到
The Action and Func delegate families are wider than you've shown - they go up to
Action<T1, T2, T3, T4>
和
Func<T1, T2, T3, T4, TResult>
.NET 2.0 中另一个常见的列表操作(在 LINQ 之前)是 Predicate<T>.
Another common-ish one in .NET 2.0 for list manipulation (before LINQ) is Predicate<T>.
使用线程:
ThreadStart
ParameterizedThreadStart
WaitCallback
TimerCallback
AsyncCallback
这篇关于C# 中的标准委托的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C# 中的标准委托
基础教程推荐
- Moq It.Is<>不匹配 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
