i want to have an enumeration that can also act as bit-flags, and have
values.
using System;
using System.Windows.Forms;
namespace MyProgram
{
class HelloEnumerations
{
[FlagsAttribute]
enum FlagColors : uint
{
Red = 0x01,
Green = 0x02,
Blue = 0x04,
}
public static void Main()
{
DoSomething(FlagColors.Red | FlagColors.Blue);
}
private static void DoSomething(uint theFlagColors)
{
System.Windows.Forms.MessageBox.Show(theFlagColors .ToString());
}
}
}
Problem is i get a compile error on the line:
DoSomething(FlagColors.Red | FlagColors.Blue);
saying "Argument '1': cannot convert from
'MyProgram.HelloEnumerations.FlagColors' to 'uint'"
Why can it not convert it to a uint? That's why i have the " : uint" in the
declaration of
enum FlagColors : uint
What magic keyword am i missing; and how to make it work without manually
casting to a (uint)?