Class BooleanConversionExtensions
- Namespace
- HeroKit.Booleans
- Assembly
- HeroKit.dll
Provides extension methods for converting boolean values.
public static class BooleanConversionExtensions
- Inheritance
-
BooleanConversionExtensions
- Inherited Members
Methods
ToInt(bool)
Converts a boolean to 1 or 0.
public static int ToInt(this bool value)
Parameters
valueboolThe boolean value to convert.
Returns
- int
1 for true; 0 for false.
ToText(bool, string, string)
Converts a boolean to one of two texts.
public static string ToText(this bool value, string trueText, string falseText)
Parameters
valueboolThe boolean value to convert.
trueTextstringThe text for true.
falseTextstringThe text for false.
Returns
- string
trueTextorfalseText.
Examples
isActive.ToText("Aktif", "Pasif");
ToText(bool?, string, string, string)
Converts a nullable boolean to one of three texts.
public static string ToText(this bool? value, string trueText, string falseText, string nullText = "-")
Parameters
valuebool?The nullable boolean value to convert.
trueTextstringThe text for true.
falseTextstringThe text for false.
nullTextstringThe text for null. Defaults to "-".
Returns
- string
trueText,falseTextornullText.
ToYesNo(bool)
Converts a boolean to "Yes" or "No".
public static string ToYesNo(this bool value)
Parameters
valueboolThe boolean value to convert.
Returns
- string
"Yes" for true; "No" for false.
ToYesNo(bool?)
Converts a nullable boolean to "Yes" or "No". Null is "No".
public static string ToYesNo(this bool? value)
Parameters
valuebool?The nullable boolean value to convert.
Returns
- string
"Yes" for true; "No" for false or null.