简体   繁体   English

64位枚举? C#

[英]64bit Enums? C#

Is it possible to get an enum to hold 64bit values?是否有可能获得一个枚举来保存 64 位值? I wrote the code below and got this compile error message.我写了下面的代码并得到了这个编译错误信息。

enum EnumTest { a = 0x100000000 };

error CS0266: Cannot implicitly convert type 'long' to 'int'.错误 CS0266:无法将类型“long”隐式转换为“int”。 An explicit conversion exists (are you missing a cast?)存在显式转换(您是否缺少演员表?)

Yes, you need to "derive" it from long.是的,您需要从 long 中“派生”它。

public enum MyEnum : long
{
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM