只是好奇,“Void”struct
除了反射?
Just of a curiosity, is there any practical use of "Void" struct
except in Reflection ?
System.Void 相当于 void 关键字。查看void的工具提示,会显示
System.Void
void
结构体System.Void
但在C#中不能直接使用,所以最好忽略它。
尝试使用 System.Void 将生成编译错误
错误CS0673:无法在C#中使用System.Void——使用typeof(void)获取void类型对象
因此,它只会落入反射的主题。
System.Void is the equivalent of the void keyword. Check the tool tip of void and it will display
struct System.Void
But it can't be used directly in C#, so you best ignore it.
Trying to use System.Void will generate a compilation error
error CS0673: System.Void cannot be used from C# -- use typeof(void) to get the void type object
So then, it will fall to the topic of reflection only.
我认为,但我不确定,编译器使用该结构为具有 void 返回类型的函数生成 il
I think, but I'm not sure, that this struct is used by the compiler to generate il for functions with void return type
文档说,
Void 结构在 System.Reflection 命名空间中使用,但在典型应用程序中很少有用。 Void 结构除了所有类型都从 Object 类继承的成员之外没有其他成员。
所以我对此表示怀疑。
Well documentation says,
The Void structure is used in the System.Reflection namespace, but is rarely useful in a typical application. The Void structure has no members other than the ones all types inherit from the Object class.
So I doubt it.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(3)
System.Void
相当于void
关键字。查看void
的工具提示,会显示但在C#中不能直接使用,所以最好忽略它。
尝试使用
System.Void
将生成编译错误因此,它只会落入反射的主题。
System.Void
is the equivalent of thevoid
keyword. Check the tool tip ofvoid
and it will displayBut it can't be used directly in C#, so you best ignore it.
Trying to use
System.Void
will generate a compilation errorSo then, it will fall to the topic of reflection only.
我认为,但我不确定,编译器使用该结构为具有 void 返回类型的函数生成 il
I think, but I'm not sure, that this struct is used by the compiler to generate il for functions with void return type
文档说,
Void 结构在 System.Reflection 命名空间中使用,但在典型应用程序中很少有用。 Void 结构除了所有类型都从 Object 类继承的成员之外没有其他成员。
所以我对此表示怀疑。
Well documentation says,
The Void structure is used in the System.Reflection namespace, but is rarely useful in a typical application. The Void structure has no members other than the ones all types inherit from the Object class.
So I doubt it.