Boolean - ToString

A bool extension method that show the trueValue when the @this value is true; otherwise show the falseValue.

Try it

public static void Main()
{
	bool thisTrue = true;
    bool thisFalse = false;

	// C# Extension Method: Boolean - ToString
    string result1 = thisTrue.ToString("Fizz", "Buzz");
    string result2 = thisFalse.ToString("Fizz", "Buzz");
	
	Console.WriteLine("value1 = {0}", result1);
	Console.WriteLine("value2 = {0}", result2);
}

View Source
public static partial class Extensions
{
    /// <summary>
    ///     A bool extension method that show the trueValue when the @this value is true; otherwise show the falseValue.
    /// </summary>
    /// <param name="this">The @this to act on.</param>
    /// <param name="trueValue">The true value to be returned if the @this value is true.</param>
    /// <param name="falseValue">The false value to be returned if the @this value is false.</param>
    /// <returns>A string that represents of the current boolean value.</returns>
    public static string ToString(this bool @this, string trueValue, string falseValue)
    {
        return @this ? trueValue : falseValue;
    }
}