T
Tyler
The MSDN help on the enum keyword for the C# language indicates that it is
possible to give an enumeration a base-type other than int. In my case, I
have chosen to give it a base type of uint.
The annoying thing I have encountered, is that when I switch on a uint
value, I still have to explicitly cast my enum values to uint - even though
they should be uint values. Is this by design (I don't know why because my
enum is uint and so is the switch value), or is there something I have
missed that would remove the required explicit uint cast?
Thanks, Tyler
Code sample:
------------
class Class1
{
protected enum eTest : uint
{
value1,
value2
};
[STAThread]
static void Main(string[] args)
{
uint tvuiValue = 1;
switch( tvuiValue )
{
case eTest.value1: // ERROR here
break;
case (uint)eTest.value2: // No error here
break;
default:
break;
}
}
}
Errors:
possible to give an enumeration a base-type other than int. In my case, I
have chosen to give it a base type of uint.
The annoying thing I have encountered, is that when I switch on a uint
value, I still have to explicitly cast my enum values to uint - even though
they should be uint values. Is this by design (I don't know why because my
enum is uint and so is the switch value), or is there something I have
missed that would remove the required explicit uint cast?
Thanks, Tyler
Code sample:
------------
class Class1
{
protected enum eTest : uint
{
value1,
value2
};
[STAThread]
static void Main(string[] args)
{
uint tvuiValue = 1;
switch( tvuiValue )
{
case eTest.value1: // ERROR here
break;
case (uint)eTest.value2: // No error here
break;
default:
break;
}
}
}
Errors: