The framework itself does not provide this for you (as far as I know). Translating true/false
into yes/no
does not strike me as more common than other potential translations (such as on/off
, checked/unchecked
, read-only/read-write
or whatever).
I imagine that the easiest way to encapsulate the behavior is to make an extension method that wraps the construct that you suggest yourself in your question:
public static class BooleanExtensions
{
public static string ToYesNoString(this bool value)
{
return value ? Resources.Yes : Resources.No;
}
}
Usage:
bool someValue = GetSomeValue();
Console.WriteLine(someValue.ToYesNoString());
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…