I wonder is there a way to prevent an enum with duplicate keys to compile?
enum
For instance this enum below will compile
public
Here's a simple unit test that checks it, should be a bit faster:
[TestMethod] public void Test() { var enums = (myEnum[])Enum.GetValues(typeof(myEnum)); Assert.IsTrue(enums.Count() == enums.Distinct().Count()); }