How many entries can an enum in .NET have?
I'm pretty certain the underlying type is an integer type (not necessarily an int
). This page here states that:
The approved types for an enum are byte, sbyte, short, ushort, int, uint, long, or ulong. The underlying type specifies how much storage is allocated for each enumerator.
and:
Just as with any constant, all references to the individual values of an enum are converted to numeric literals at compile time.
So I would suggest the only limitation will be the range of long/ulong
(well into the billions) and the allowable symbol space in the compiler for enumerations (you'll most likely strike that limitation first if you're actually creating truly massive enumerations).
If you specify a smaller type for your enumeration (e.g., short
), the range will be reduced accordingly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With