Table of Contents

Struct Trilean

Namespace
Echo
Assembly
Echo.dll

Represents a ternary boolean (true, false or unknown) value.

public readonly struct Trilean
Inherited Members

Constructors

Trilean(TrileanValue)

Creates a new trilean.

public Trilean(TrileanValue value)

Parameters

value TrileanValue

The trilean value.

Trilean(bool)

Creates a new trilean.

public Trilean(bool value)

Parameters

value bool

The boolean value.

Trilean(bool?)

Creates a new trilean.

public Trilean(bool? value)

Parameters

value bool?

The nullable boolean value. If the value is null, Unknown will be assumed.

Fields

False

Represents the false value.

public static readonly Trilean False

Field Value

Trilean

True

Represents the true value.

public static readonly Trilean True

Field Value

Trilean

Unknown

Represents the unknown value.

public static readonly Trilean Unknown

Field Value

Trilean

Properties

IsKnown

Gets a value indicating whether the value is known (either true or false).

public bool IsKnown { get; }

Property Value

bool

IsUnknown

Gets a value indicating whether the value is unknown.

public bool IsUnknown { get; }

Property Value

bool

Value

Gets the raw integer representation of the trilean value.

public TrileanValue Value { get; }

Property Value

TrileanValue

Methods

And(Trilean)

Computes the and between two trilean values.

public Trilean And(Trilean other)

Parameters

other Trilean

The other trilean value.

Returns

Trilean

Returns true if both values are true. If not, returns unknown if at least one is true or unknown and the other is unknown, and false otherwise.

Equals(Trilean)

Determines whether this trilean is exactly equal to the specified trilean.

public bool Equals(Trilean other)

Parameters

other Trilean

The other trilean.

Returns

bool

true if the Value property of both trileans are equal, false otherwise.

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

FromChar(char)

Obtains the trilean value that is associated to the provided character.

public static Trilean FromChar(char c)

Parameters

c char

The character to parse.

Returns

Trilean

The trilean value.

Exceptions

FormatException

Occurs when the character is not a valid trilean digit.

GetHashCode()

public override int GetHashCode()

Returns

int

Not()

Inverts the trilean value.

public Trilean Not()

Returns

Trilean

Returns true if the value is false, and vice versa. If unknown, the return value is also unknown.

Or(Trilean)

Computes the inclusive or between two trilean values.

public Trilean Or(Trilean other)

Parameters

other Trilean

The other trilean value.

Returns

Trilean

Returns true if at least one of the values is true. If neither are true, returns unknown if at least one is unknown, and false otherwise.

ToBoolean()

When the trilean value is known, obtains the boolean value.

public bool ToBoolean()

Returns

bool

The boolean value.

ToBooleanOrFalse()

When the trilean value is known, obtains the boolean value, otherwise returns false.

public bool ToBooleanOrFalse()

Returns

bool

The boolean value.

ToChar()

Returns the raw value of the trilean as a single character (either '0', '1' or '?').

public char ToChar()

Returns

char

The character.

ToNullableBoolean()

Converts the trilean to a nullable boolean, where null indicates the unknown state.

public bool? ToNullableBoolean()

Returns

bool?

The nullable boolean.

ToString()

public override string ToString()

Returns

string

Xor(Trilean)

Computes the exclusive or between two trilean values.

public Trilean Xor(Trilean other)

Parameters

other Trilean

The other trilean value.

Returns

Trilean

Returns true if the two trilean values are different. If at least one is unknown, the result is unknown.

Operators

operator &(Trilean, Trilean)

Computes the and between two trilean values.

public static Trilean operator &(Trilean a, Trilean b)

Parameters

a Trilean

The left hand side of the binary operator.

b Trilean

The right hand side of the binary operator.

Returns

Trilean

Returns true if both values are true. If not, returns unknown if at least one is true or unknown and the other is unknown, and false otherwise.

operator |(Trilean, Trilean)

Computes the inclusive or between two trilean values.

public static Trilean operator |(Trilean a, Trilean b)

Parameters

a Trilean

The left hand side of the binary operator.

b Trilean

The right hand side of the binary operator.

Returns

Trilean

Returns true if at least one of the values is true. If neither are true, returns unknown if at least one is unknown, and false otherwise.

operator ==(Trilean, Trilean)

Determines whether this trilean is exactly equal to the specified trilean.

public static bool operator ==(Trilean a, Trilean b)

Parameters

a Trilean

The left hand side of the comparison.

b Trilean

The right hand side of the comparison.

Returns

bool

true if the Value property of both trileans are equal, false otherwise.

operator ^(Trilean, Trilean)

Computes the exclusive or between two trilean values.

public static Trilean operator ^(Trilean a, Trilean b)

Parameters

a Trilean

The left hand side of the binary operator.

b Trilean

The right hand side of the binary operator.

Returns

Trilean

Returns true if the two trilean values are different. If at least one is unknown, the result is unknown.

operator false(Trilean)

Determines whether the trilean is false.

public static bool operator false(Trilean value)

Parameters

value Trilean

The trilean.

Returns

bool

false if the Value property is False, false otherwise.

implicit operator Trilean(TrileanValue)

Creates a new trilean.

public static implicit operator Trilean(TrileanValue value)

Parameters

value TrileanValue

The trilean value.

Returns

Trilean

implicit operator Trilean(bool)

Creates a new trilean.

public static implicit operator Trilean(bool value)

Parameters

value bool

The boolean value.

Returns

Trilean

implicit operator Trilean(bool?)

Creates a new trilean.

public static implicit operator Trilean(bool? value)

Parameters

value bool?

The trilean value.

Returns

Trilean

operator !=(Trilean, Trilean)

Determines whether this trilean is not equal to the specified trilean.

public static bool operator !=(Trilean a, Trilean b)

Parameters

a Trilean

The left hand side of the comparison.

b Trilean

The right hand side of the comparison.

Returns

bool

true if the Value property of both trileans are different, false otherwise.

operator !(Trilean)

Inverts the trilean value.

public static Trilean operator !(Trilean value)

Parameters

value Trilean

The value to invert.

Returns

Trilean

Returns true if the value is false, and vice versa. If unknown, the return value is also unknown.

operator true(Trilean)

Determines whether the trilean is true.

public static bool operator true(Trilean value)

Parameters

value Trilean

The trilean.

Returns

bool

true if the Value property is True, false otherwise.