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
valueTrileanValueThe trilean value.
Trilean(bool)
Creates a new trilean.
public Trilean(bool value)
Parameters
valueboolThe boolean value.
Trilean(bool?)
Creates a new trilean.
public Trilean(bool? value)
Parameters
Fields
False
Represents the false value.
public static readonly Trilean False
Field Value
True
Represents the true value.
public static readonly Trilean True
Field Value
Unknown
Represents the unknown value.
public static readonly Trilean Unknown
Field Value
Properties
IsKnown
Gets a value indicating whether the value is known (either true or false).
public bool IsKnown { get; }
Property Value
IsUnknown
Gets a value indicating whether the value is unknown.
public bool IsUnknown { get; }
Property Value
Value
Gets the raw integer representation of the trilean value.
public TrileanValue Value { get; }
Property Value
Methods
And(Trilean)
Computes the and between two trilean values.
public Trilean And(Trilean other)
Parameters
otherTrileanThe 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
otherTrileanThe other trilean.
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
FromChar(char)
Obtains the trilean value that is associated to the provided character.
public static Trilean FromChar(char c)
Parameters
ccharThe 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
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
otherTrileanThe 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
Xor(Trilean)
Computes the exclusive or between two trilean values.
public Trilean Xor(Trilean other)
Parameters
otherTrileanThe 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
aTrileanThe left hand side of the binary operator.
bTrileanThe 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
aTrileanThe left hand side of the binary operator.
bTrileanThe 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
Returns
operator ^(Trilean, Trilean)
Computes the exclusive or between two trilean values.
public static Trilean operator ^(Trilean a, Trilean b)
Parameters
aTrileanThe left hand side of the binary operator.
bTrileanThe 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
valueTrileanThe trilean.
Returns
implicit operator Trilean(TrileanValue)
Creates a new trilean.
public static implicit operator Trilean(TrileanValue value)
Parameters
valueTrileanValueThe trilean value.
Returns
implicit operator Trilean(bool)
Creates a new trilean.
public static implicit operator Trilean(bool value)
Parameters
valueboolThe boolean value.
Returns
implicit operator Trilean(bool?)
Creates a new trilean.
public static implicit operator Trilean(bool? value)
Parameters
valuebool?The trilean value.
Returns
operator !=(Trilean, Trilean)
Determines whether this trilean is not equal to the specified trilean.
public static bool operator !=(Trilean a, Trilean b)
Parameters
Returns
operator !(Trilean)
Inverts the trilean value.
public static Trilean operator !(Trilean value)
Parameters
valueTrileanThe 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
valueTrileanThe trilean.