DotNext by Roman Sakno

<PackageReference Include="DotNext" Version="0.2.0" />

 Variant<T1, T2>

Represents value that can be one of two possible types.
public Optional<T1> First { get; }

Interprets stored value as T1.

public bool IsPresent { get; }

Indicates that this container stores non-null value.

public Optional<T2> Second { get; }

Interprets stored value as T2.

public Variant(T1 value)

Creates a new variant value from value of type T1.

public Variant(T2 value)

Creates a new variant value from value of type T2.

public static bool op_Equality(Variant<T1, T2> first, Variant<T1, T2> second)

Determines whether the two variant values are equal.

public static T1 op_Explicit(Variant<T1, T2> var)

Converts variant value into type T1.

public static T2 op_Explicit(Variant<T1, T2> var)

Converts variant value into type T2.

public static bool op_False(Variant<T1, T2> variant)

Indicates that variant value is null value.

public static Variant<T1, T2> op_Implicit(T1 value)

Converts value of type T1 into variant.

public static Variant<T1, T2> op_Implicit(T2 value)

Converts value of type T2 into variant.

public static bool op_Inequality(Variant<T1, T2> first, Variant<T1, T2> second)

Determines whether the two variant values are not equal.

public static bool op_True(Variant<T1, T2> variant)

Indicates that variant value is non-null value.

public Optional<R> Convert<R>(Converter<T1, R> mapper1, Converter<T2, R> mapper2)

Converts the stored value.

public Variant<U1, U2> Convert<U1, U2>(Converter<T1, U1> mapper1, Converter<T2, U2> mapper2)

Converts this variant value into another value.

public bool Equals<V>(V other) where V : IVariant

Determines whether the value stored in this variant container is equal to the value stored in the given variant container.

public Variant<T2, T1> Permute()

Change order of type parameters.