I'm currently working on a C# program that utilizes a fair number of enums. It's organized in such a way that a class contains many enums, and there are several of these classes. However, a couple enums are identical between the two--for organizational purposes, it would be nice to have a kind of 'SharedEnums' class, and then do something like this:
public class FirstEnumCollection {
public enum Fruits = SharedEnums.Fruits;
//insert non-shared enums here
}
public class FirstEnumCollection {
public enum Fruits = SharedEnums.Fruits;
//insert non-shared enums here
}
public class SharedEnums {
public enum Fruits {
Apple,
Pear
}
}
This way, we won't have the same enums declared multiple times across classes, and changing the shared enum will change the enum in both classes. I've tried several variations of my example without luck, and I'm fairly certain it can't be done, but would like confirmation.