Can .NET convert "Yes" & "No" to boolean without If?

C# 6+ version:

public static bool StringToBool(string value) => 
    value.Equals("yes",           StringComparison.CurrentCultureIgnoreCase) ||
    value.Equals(bool.TrueString, StringComparison.CurrentCultureIgnoreCase) || 
    value.Equals("1");`

If you think about it, "yes" cannot be converted to bool because it is a language and context specific string.

"Yes" is not synonymous with true (especially when your wife says it...!). For things like that you need to convert it yourself; "yes" means "true", "mmmm yeeessss" means "half true, half false, maybe", etc.


No, but you could do something like:

bool yes = "Yes".Equals(yourString);


Using this way, you can define conversions from any string you like, to the boolean value you need. 1 is true, 0 is false, obviously.
Benefits: Easily modified. You can add new aliases or remove them very easily.
Cons: Will probably take longer than a simple if. (But if you have multiple alises, it will get hairy)

enum BooleanAliases {
      Yes = 1,
      Aye = 1,
      Cool = 1,
      Naw = 0,
      No = 0
 }
 static bool FromString(string str) {
      return Convert.ToBoolean(Enum.Parse(typeof(BooleanAliases), str));
 }
 // FromString("Yes") = true
 // FromString("No") = false
 // FromString("Cool") = true