c# - .NET 中是否有 "Void"结构的实际用途

标签 c# .net void

只是好奇,“Void”有什么实际用途吗 struct

除了反射?

最佳答案

System.Void 等同于 void 关键字。查看void的工具提示,会显示

struct System.Void

但是在C#中不能直接使用,所以你最好忽略它。

尝试使用 System.Void 会产生编译错误

error CS0673: System.Void cannot be used from C# -- use typeof(void) to get the void type object

那么,就只剩下反射(reflection)的话题了。

关于c# - .NET 中是否有 "Void"结构的实际用途,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3579197/

相关文章:

c# - 无法将类型为 'System.Security.Claims.ClaimsIdentity' 的对象转换为类型 'System.Security.Principal.WindowsIdentity'

.net - 为什么 .NET Framework 中没有 ObservableKeyedCollection<TKey, TValue>?

c - 返回平均值、最大值、最小值的 Void 函数,并以数组和输入数量作为参数

c# - 获取正在运行的进程的维度

c# - 使用 Fluent NHibernate AutoMapping 进行级联保存 - 旧答案仍然有效吗?

.net - 生成“路径中的非法字符”错误的空白.net文件

java - 应该返回值的方法可以像不返回任何内容(void)的方法一样使用吗?

c# - Chrome驱动Selenium下载位置

c# - 使用 FormatConvertedBitmap 从 Pbgra32 转换为 Bgr32 PixelFormats

c++ - 我似乎找不到声明 char a[] 和 char b[] 的适当方法