简体   繁体   中英

64bit Enums? C#

Is it possible to get an enum to hold 64bit values? I wrote the code below and got this compile error message.

enum EnumTest { a = 0x100000000 };

error CS0266: Cannot implicitly convert type 'long' to 'int'. An explicit conversion exists (are you missing a cast?)

Yes, you need to "derive" it from long.

public enum MyEnum : long
{
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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