Set a string value for boolean True/False

bondra

Well-known member
Joined
Oct 24, 2020
Messages
77
Programming Experience
Beginner
Is it possible to output a boolean value True/False to say Yes/No instead?
 
What wrong with using an extension method ?
C#:
public static class BooleanExtensions
{
    public static string YesNo(this bool value) => value ? "Yes" : "No";
}

:

bool iLoveCode = true;
Console.WriteLine(iLoveCode.YesNo());
 
Last edited:
Back
Top Bottom