DotNext by Roman Sakno

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

 Variant<T1, T2>

public struct Variant<T1, T2> : IEquatable<Variant<T1, T2>>, IVariant, IDynamicMetaObjectProvider
Represents value that can be one of two possible types.
public Optional<T1> First { get; }

Interprets stored value as T1.

public bool IsNull { 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<TResult> Convert<TResult>(ref ValueFunc mapper1, ref ValueFunc mapper2)

Converts the stored value.

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

Converts the stored value.

public Variant<TResult1, TResult2> Convert<TResult1, TResult2>(ref ValueFunc mapper1, ref ValueFunc mapper2)

Converts this variant value into another value.

public Variant<TResult1, TResult2> Convert<TResult1, TResult2>(Converter<T1, TResult1> mapper1, Converter<T2, TResult2> mapper2)

Converts this variant value into another value.

public void Deconstruct(out T1 value1, out T2 value2)

Deconstructs this object.

public bool Equals<TOther>(TOther other) where TOther : 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.