ThisToThat/ThisToThat/ToBooleanExtensions.cs
/// <summary>
/// Converts and returns this string's value as a nullable boolean.
/// Values which will convert to true are: "TRUE", "T", "YES", "Y", "ON", "1"
/// Values which will convert to false are: "FALSE", "F", "NO", "N", "OFF", "0"
/// All other values will convert to null.
/// </summary>
Converts and returns this string's value as a nullable boolean.
Converts and returns this string ' s value as a nullable boolean .
public static bool? ToBooleanNullable(this string thisString)
        {
            bool? returnValue = null;
            if (_TRUE_STRINGS.Contains(thisString.ToUpper()))
                returnValue = true;
            else if (_FALSE_STRINGS.Contains(thisString.ToUpper()))
                returnValue = false;
            return returnValue;
        }
public static bool ? ToBooleanNullable ( this string thisString ) { bool ? returnValue = null ; if ( _TRUE_STRINGS . Contains ( thisString . ToUpper ( ) ) ) returnValue = true ; else if ( _FALSE_STRINGS . Contains ( thisString . ToUpper ( ) ) ) returnValue = false ; return returnValue ; }
Converts and returns this string's value as a nullable boolean.
Converts and returns this string ' s value as a nullable boolean .
string
this