are there function pointers in c#?(c#中有函数指针吗?)
问题描述
我正在尝试学习一些 c# 编码,并想知道 c# 中是否包含函数指针的 c++ 概念.我看到有诸如代表之类的东西.它们是同一个概念吗?还是它们在更基本的层面上有所不同?
I am trying to learn some c# coding and wondering if the c++ concept of function pointers is included in c#. I see there are such things as delegates. Are they the same concept? or do they differ on a more fundamental level?
推荐答案
委托本质上是函数指针,但是内置了额外的多播能力.所以你可以将多个函数分配给同一个委托,它们都会被依次调用当委托被调用时.
Delegates are essentially function pointers, but with extra multicast capabilities built in. So you can assign several functions to the same delegate, and they will all be called in sequence when the delegate is called.
委托还具有内置的异步接口,并且在将新功能分配给委托时(以及在 .NET 4 中,在传递委托时)具有共同/相反的差异
Delegates also have built-in asynchronous interfaces, and have co/contra variance when assigning new functions to a delegate (and, in .NET 4, when passing delegates around)
这篇关于c#中有函数指针吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:c#中有函数指针吗?


- MoreLinq maxBy vs LINQ max + where 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 输入按键事件处理程序 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01