Share via


SumType<T1,T2> Struct

Definition

Struct that may contain a T1 or a T2.

generic <typename T1, typename T2>
public value class SumType : IEquatable<Microsoft::VisualStudio::LanguageServer::Protocol::SumType<T1, T2>>, Microsoft::VisualStudio::LanguageServer::Protocol::ISumType
[Newtonsoft.Json.JsonConverter(typeof(Microsoft.VisualStudio.LanguageServer.Protocol.SumConverter))]
public struct SumType<T1,T2> : IEquatable<Microsoft.VisualStudio.LanguageServer.Protocol.SumType<T1,T2>>, Microsoft.VisualStudio.LanguageServer.Protocol.ISumType
[<Newtonsoft.Json.JsonConverter(typeof(Microsoft.VisualStudio.LanguageServer.Protocol.SumConverter))>]
type SumType<'T1, 'T2> = struct
    interface ISumType
Public Structure SumType(Of T1, T2)
Implements IEquatable(Of SumType(Of T1, T2)), ISumType

Type Parameters

T1

The first type this struct is designed to contain.

T2

The second type this struct is designed to contain.

Inheritance
SumType<T1,T2>
Attributes
Newtonsoft.Json.JsonConverterAttribute
Implements

Constructors

SumType<T1,T2>(T1)

Initializes a new instance of the SumType<T1,T2> struct containing a T1.

SumType<T1,T2>(T2)

Initializes a new instance of the SumType<T1,T2> struct containing a T2.

Properties

First

Gets the value as the first specified type.

Second

Gets the value as the second specified type.

Value

Gets the value stored in the SumType. This can be matched against using the "is" operator.

Methods

Equals(Object)

Indicates whether this instance and a specified object are equal.

Equals(SumType<T1,T2>)

Indicates whether the current object is equal to another object of the same type.

GetHashCode()

Returns the hash code for this instance.

Match<TResult>(Func<T1,TResult>, Func<T2,TResult>, Func<TResult>)

Runs a delegate corresponding to which type is contained inside this instance.

TryGetFirst(T1)

Tries to get the value as the first specified type.

TryGetSecond(T2)

Tries to get the value as the second specified type.

Operators

Equality(SumType<T1,T2>, SumType<T1,T2>)
Explicit(SumType<T1,T2> to T1)

Attempts to cast an instance of SumType<T1,T2> to an instance of T1.

Explicit(SumType<T1,T2> to T2)

Attempts to cast an instance of SumType<T1,T2> to an instance of T2.

Implicit(T1 to Nullable<SumType<T1,T2>>)
Implicit(T1 to SumType<T1,T2>)
Implicit(T2 to Nullable<SumType<T1,T2>>)
Implicit(T2 to SumType<T1,T2>)
Inequality(SumType<T1,T2>, SumType<T1,T2>)

Applies to