我有以下枚举定义(在C#中):
public enum ELogLevel
{
General = -1, // Should only be used in drop-down box in Merlinia Administrator log settings
All = 0, // Should not be used as a level, only as a threshold, effectively same as Trace
Trace = 1,
Debug = 2,
Info = 3,
Warn = 4,
Error = 5,
Fatal = 6,
Off = 7 // Should not be used as a level, only as a threshold
}
Run Code Online (Sandbox Code Playgroud)
现在,当我Enum.GetNames()在这个类型上做一个我得到一个包含9个元素的字符串数组,但顺序是All,Trace,...,Off,General,这不是我所期待的.
下面是MSDN 文档为Enum.GetNames():
"备注:返回值数组的元素按枚举常量的值排序."
这里发生了什么?我可以改变我的程序来考虑这个"功能",但我想知道为什么.NET正在做它正在做的事情.
| 归档时间: |
|
| 查看次数: |
2121 次 |
| 最近记录: |