C# - 都枚举常量? [英] C# - are all Enum constants?

查看:193
本文介绍了C# - 都枚举常量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否所有枚举枚举常量?他们得到的转换为自己的价值在编译时,或在运行时?

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.

参考: http://msdn.microsoft.com/en-us/library/sbbt4032.aspx

从介绍:

enum关键字用于声明   一个枚举,一个独特的类型   由一组的命名常量   所谓枚举列表。

The enum keyword is used to declare an enumeration, a distinct type that consists of a set of named constants called the enumerator list.

在可靠编程:

正如任何常量,所有   引用的各个值   枚举的转换为数字   文字在编译时。这可   造成潜在的版本问题   常量描述(C#编程   指南)。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆