How do I use unsafe values in an enum?
Posted
by Jon Tackabury
on Stack Overflow
See other posts from Stack Overflow
or by Jon Tackabury
Published on 2010-04-12T15:57:49Z
Indexed on
2010/04/12
16:02 UTC
Read the original article
Hit count: 345
I need to use this enum in my C# application, but it won't let me use these values. When I specify the type as uint I can use the -1 value, and when I specify int I can't use the last 2 values. Is there a way to use the unchecked keyword here to allow me to define all of these values? These values are coming from an external source, so I can't change them.
internal enum MyValues : int
{
value1 = -1,
value2 = 0,
value3 = 0x80000000,
value4 = 0xFFFFFFFF
}
© Stack Overflow or respective owner