namespace Foo
{
public enum MyEnum
{
High, Low
}
public class Class1
{
public MyEnum MyProperty { get; set; }
}
}
MyEnum is declared outside Class1
cause I need it here and in other classes
Seems good, but what if I decide later to delete the file containingClass1?
MyEnum declaration will be lost!!
What’s the best practice to code shared enums between classes?
The best practice is creating separate file for each class, enum, or other type.
MyEnum.cs
Class1.cs