public static class StringExtensions
{
private static readonly string[] ValidString =
new[] {"true", "t", "1", "yes", "y"};
public static bool TryConvertToBoolean(this string input)
{
try
{
if (input == null) return false;
input = input.Trim().ToLower();
return ValidString.Contains(input);
}
catch
{
return false;
}
}
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.