user34537
user34537

Reputation:

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?)

Upvotes: 21

Views: 5300

Answers (1)

Oliver Hanappi
Oliver Hanappi

Reputation: 12346

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

public enum MyEnum : long
{
}

Upvotes: 47

Related Questions