Table of Contents

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

value bool

The 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

value bool

The boolean value to convert.

trueText string

The text for true.

falseText string

The text for false.

Returns

string

trueText or falseText.

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

value bool?

The nullable boolean value to convert.

trueText string

The text for true.

falseText string

The text for false.

nullText string

The text for null. Defaults to "-".

Returns

string

trueText, falseText or nullText.

ToYesNo(bool)

Converts a boolean to "Yes" or "No".

public static string ToYesNo(this bool value)

Parameters

value bool

The 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

value bool?

The nullable boolean value to convert.

Returns

string

"Yes" for true; "No" for false or null.