Casting Y or N to bool C#

Viewed 20223

Just for neatness sake I was wondering, whether it's possible to cast Y or N to a bool? Something like this;

bool theanswer = Convert.ToBoolean(input);

The long version;

bool theanswer = false;
switch (input)
{
   case "y": theanswer = true; break;
   case "n": theanswer = false; break
}
10 Answers
Related