什么是公开]的目的;价值__"场,我可以在反射器对我的枚举看?

人气:1,024 发布:2022-09-10 标签: .net enums reflector

问题描述

我在看我在反射器中创建一个枚举,有一个所谓的价值__。

I am looking at an enum I created in Reflector and there is a public integer field called "value__".

这件的目的是什么?

一个链接或引用文件是好的一个答案。

A link or reference to a document is fine for an answer.

谷歌搜索是一种痛苦,因为value__将返回命中为价值。

Googling is a pain because "value__" is returning hits for "value".

我一直在寻找了近一个小时,才发现下面的链接。其中大部分是在不同的位点相同的制品。他们都展示了​​如何通过反射访问成员,但他们没有解释什么的成员是。

I have been searching for nearly an hour and only found the links below. Most of these are the same article on different sites. They all show how to access the member via reflection but none of them explain what the member is for.

http://powershell.com/cs/forums/p/462/ 599.aspx

http://tfl09.blogspot.com/一十二分之二千零八/枚举,枚举值和 - powershell.html

C#函数,它接受一个枚举项,并返回枚举值(而不是索引)

http://www.mail-archive.com/ dotnet@discuss.develop.com/msg02431.html

更新

最后一个环节下面讨论(在底部),你不能使用value__作为一个枚举值,因为它是RESERVERD但没有说为什么。

The last link below discusses (at the bottom) that you can't use value__ as an enum value as it is reserverd but does not say why.

http://www.vijaymukhi.com/documents/books/csadv/ chap3.htm

更新2

下面的环节是MSDN的页面编译器错误还写着value__被保留。但仍然没有喜悦的发现什么成员呢......

The link below is to the MSDN page that for the compiler error that also says "value__" is reserved. But still no joy an finding out what the member does....

http://msdn.microsoft。 COM / EN-US /库/ e3988xhs(V = vs.71)的.aspx

推荐答案

JIT编译器需要描述其布局时,它被装箱值类型的定义。他们大多是烤成mscorlib程序,如System.Int32的。在枚举的关键字,您可以创建一个新的价值类型。在元数据为它的编译器必须因此提供的定义。这是你在​​找什么。你会看到每个枚举成员()静态字段,使用的ToString。而一个实例字段名value__存储枚举值。关键的一点是,这种只存在于枚举值的盒装版。

The JIT compiler needs a definition of a value type that describes its layout when it gets boxed. Most of them are baked into mscorlib, like System.Int32. The enum keyword lets you create a new value type. The compiler must thus provide a definition for it in the metadata. Which is what you are looking at. You'll see static fields for each enumeration member, used by ToString(). And one instance field name value__ that stores the enumeration value. Key point is that this only exists in the boxed version of an enum value.

121