I was under the impression that the int values behind enums were unique. Therefore if you assign the ints manually and accidentally duplicate a value then it should fail at compile time.
Why does the following code compile ok and is there a way to force this to fail in order to prevent accidental duplicaiton?
class Program
{
static void Main(string[] args)
{
Test a = Test.A;
}
}
enum Test
{
A = 1,
B = 1,
}