Background
In a C# command-line app I’m writing, several of the parameters have ‘yes’ and ‘no’ as the possible values.
I am storing their input using the Enum type shown below.
enum YesNo { Yes, No }
Which is fine – the code works. No problem there.
NOTE: Yes, I could store these as bool (that’s how it used to work). My design choice is to be explicit about the Yes/No choice made by the user because they will see this printed in other contexts and I’d like it to be more obvious what the choice was.
My Question
- It just seems odd to have an enum called ‘YesNo’ – what are some suggestions for better names for an enum for ‘yes’ and ‘no’ values.
So Finally
I asked this question relatively early in StackOverflow’s life. It wasn’t fake question – I really did have this situation. I just thought it would be nice to use it see what the community would do. Because it is, I admit a somewhat odd question.
First, thanks to all who spent the time replying. I’m trying to pay that back with a thoughtful conclusion.
Comments on the answers
switching to bool. I understand your motivation, but I feel I need to point out that having a binary choice (and by that I mean a choice between any two values – alive/dead, married/unmarried, etc.) is not the same as boolean choice between true and false. We find as programmers switching between yes/no and true/false easy – fair enough. Had my choice in this case been for example ‘Democrat’ or ‘Replication” (contrived example, I know) then you can see possibilities for confusion or at least awkwardness. I do think the bool option is valid in this case, but less so in other binary choices.
localization – great point. In my specific case it didn’t matter – this was not and is never going to be localized, but for other situations it is something to consider.
more than three options – In fact, later on I had to add a third value called to represent the valid (in my application) condition of a user specifically not making the choice.
There were a lot of good comments, thank you all!
I’d suggest you use a name that indicates the Value which is set to Yes or No.
E.G.