C# - 都是枚举常数? [英] C# - are all Enum constants?
问题描述
在编译时,他们是不变的是的,编译时间。
参考:
http://msdn.microsoft.com/en-us/library/sbbt4032.aspx
从介绍: / p>
枚举关键字用于声明
一个枚举,一个独特的类型,
由一组命名常量
调用枚举器列表。
在鲁棒编程下:
正如任何常量一样,
的个人值的所有
引用都将转换为数字
文字在编译时。这可以
在常量(C#Programming
Guide)中描述的
创建潜在的版本控制问题。
Are all Enum enumerations constants? Do they get converted to their value at compile-time, or at run-time?
They are constant. Yes, compile time.
Reference: http://msdn.microsoft.com/en-us/library/sbbt4032.aspx
From the intro:
The enum keyword is used to declare an enumeration, a distinct type that consists of a set of named constants called the enumerator list.
Under "Robust Programming":
Just as with any constant, all references to the individual values of an enum are converted to numeric literals at compile time. This can create potential versioning issues as described in Constants (C# Programming Guide).
这篇关于C# - 都是枚举常数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!