I am currently using an enumeration to describe a number of possible operating system platforms. I have things WIN32, SOLARIS64, LINUX32, but also broader categories like ALLWIN and ALLUNIX. I have a place in my code where I need to decide if a given Platform falls into the category of another one. To me, this sounded like inheritance, but obviously enumerations can’t inherit from each other.
I then had the thought of turning these Platforms from 1 enumeration into empty classes that inherit from each other. I feel like this is a terrible idea conceptually and spatially, but not being a master of C# I thought I’d post here looking for some more experienced opinions. Any thoughts?
This would look something like:
public class ALL {};
public class ALLWIN : ALL {};
public class WINNT : ALLWIN{};
public class WIN32 : WINNT{};
…
And so on and so forth.
You want to stick with enumerations for this. You can do the checking via a bitmask. Something along the lines of:
And when you’re checking to see if the platform is of a specific system, you’ll do so by doing a bitwise AND as in the following code:
Does that make sense?