EitherOr<Ta, Tb>

References
public readonly struct EitherOr<Ta, Tb>
A pair of values, only one of which is usually set.
Ta
Tb

Constructors

EitherOr

#
public EitherOr(Ta a, Tb b)
Create an instance containing both an A and a B value.
a (Ta)
b (Tb)

EitherOr

#
public EitherOr(Ta a)
Create an instance containing only an A value.
a (Ta)

EitherOr

#
public EitherOr(Tb b)
Create an instance containing only a B value.
b (Tb)

Properties

A

#
public Ta A { get; }
The Ta value, or default(Ta) if unset.

B

#
public Tb B { get; }
The Tb value, or default(Tb) if unset.

HasA

#
public bool HasA { get; }
Gets whether the A value has been set. Note that A may still be null or default.

HasAny

#
public bool HasAny { get; }
Gets whether either A, or B or both have been set.

HasB

#
public bool HasB { get; }
Gets whether the B value has been set. Note that B may still be null or default.

HasNeither

#
public bool HasNeither { get; }
Gets whether neither A nor B have been set.

Methods

AddA

#
public EitherOr<Ta, Tb> AddA(Ta a)
Add or overwrite the A value, do not modify the B value.
a (Ta)

AddB

#
public EitherOr<Ta, Tb> AddB(Tb b)
Add or overwrite the B value, do not modify the A value.
b (Tb)

Equals

#
public override bool Equals(object obj)
obj (object)
ValueType.Equals

GetHashCode

#
public override int GetHashCode()

WithA

#
public EitherOr<Ta, Tb> WithA(Ta a)
Overwrite the A value, clear the B value.
a (Ta)

WithB

#
public EitherOr<Ta, Tb> WithB(Tb b)
Overwrite the A value, clear the B value.
b (Tb)

Operators

OperationResultDescription
EitherOr<Ta, Tb>==EitherOr<Ta, Tb>bool
EitherOr<Ta, Tb>!=EitherOr<Ta, Tb>bool