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#中有函数指针吗?


基础教程推荐
- 将 XML 转换为通用列表 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 如何激活MC67中的红灯 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- c# Math.Sqrt 实现 2022-01-01