Struct Union<T1, T2>
Represents a union of two types
Implements
Inherited Members
Namespace: ClingoSharp
Assembly: ClingoSharp.dll
Syntax
public struct Union<T1, T2> : IEquatable<Union<T1, T2>>, IComparable, IComparable<Union<T1, T2>>, ICloneable, IFormattable
Type Parameters
Name | Description |
---|---|
T1 | |
T2 |
Constructors
| Improve this Doc View SourceUnion(T1)
Creates a union with T1
value.
Declaration
public Union(T1 value)
Parameters
Type | Name | Description |
---|---|---|
T1 | value | A |
Union(T2)
Creates a union with T2
value.
Declaration
public Union(T2 value)
Parameters
Type | Name | Description |
---|---|---|
T2 | value | A |
Methods
| Improve this Doc View SourceClone()
Declaration
public object Clone()
Returns
Type | Description |
---|---|
System.Object |
CompareTo(Union<T1, T2>)
Declaration
public int CompareTo(Union<T1, T2> other)
Parameters
Type | Name | Description |
---|---|---|
Union<T1, T2> | other |
Returns
Type | Description |
---|---|
System.Int32 |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | if the Union<T1, T2> is not comparable |
CompareTo(Object)
Declaration
public int CompareTo(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
System.Int32 |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | if the Union<T1, T2> is not comparable |
Equals(Union<T1, T2>)
Indicates whether the current Union<T1, T2> is equal to another Union<T1, T2>.
Declaration
public bool Equals(Union<T1, T2> other)
Parameters
Type | Name | Description |
---|---|---|
Union<T1, T2> | other | A Union<T1, T2> to compare with this object |
Returns
Type | Description |
---|---|
System.Boolean |
|
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
Get(Type)
Gets a value.
Declaration
public object Get(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type of the value |
Returns
Type | Description |
---|---|
System.Object | The result value |
Exceptions
Type | Condition |
---|---|
System.FieldAccessException | The union is not the type setted |
Get<T>()
Gets a value.
Declaration
public T Get<T>()
Returns
Type | Description |
---|---|
T | The result value |
Type Parameters
Name | Description |
---|---|
T | The type of the value |
Exceptions
Type | Condition |
---|---|
System.FieldAccessException | The union have not a |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
Overrides
IsType(Type)
Checks if the union has the type setted.
Declaration
public bool IsType(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type of the union |
Returns
Type | Description |
---|---|
System.Boolean | True if the union has the type setted, false otherwise |
IsType<T>()
Checks if the union has the type setted.
Declaration
public bool IsType<T>()
Returns
Type | Description |
---|---|
System.Boolean | True if the union has the type setted, false otherwise |
Type Parameters
Name | Description |
---|---|
T | The type of the union |
Set(T1)
Sets the union as T1
value.
Declaration
public void Set(T1 value)
Parameters
Type | Name | Description |
---|---|---|
T1 | value | A |
Set(T2)
Sets the union as T2
value.
Declaration
public void Set(T2 value)
Parameters
Type | Name | Description |
---|---|---|
T2 | value | A |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |
Overrides
ToString(String, IFormatProvider)
Declaration
public string ToString(string format, IFormatProvider formatProvider)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | |
System.IFormatProvider | formatProvider |
Returns
Type | Description |
---|---|
System.String |
TryGet(Type, out Object)
Tries to get a value.
Declaration
public bool TryGet(Type type, out object value)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type of the value |
System.Object | value | The result value |
Returns
Type | Description |
---|---|
System.Boolean | True if the union has setted the value with |
TryGet<T>(out T)
Tries to get a value.
Declaration
public bool TryGet<T>(out T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The result value |
Returns
Type | Description |
---|---|
System.Boolean | True if the union has setted the value with |
Type Parameters
Name | Description |
---|---|
T | The type of the value |
Operators
| Improve this Doc View SourceEquality(Union<T1, T2>, Object)
Indicates whether the current Union<T1, T2> is equal to another Union<T1, T2>.
Declaration
public static bool operator ==(Union<T1, T2> union, object other)
Parameters
Type | Name | Description |
---|---|---|
Union<T1, T2> | union | The Union<T1, T2> value |
System.Object | other | An object to compare with |
Returns
Type | Description |
---|---|
System.Boolean |
|
GreaterThan(Union<T1, T2>, Object)
Compares the current instance with another object of the same type.
Declaration
public static bool operator>(Union<T1, T2> union, object other)
Parameters
Type | Name | Description |
---|---|---|
Union<T1, T2> | union | The Union<T1, T2> value |
System.Object | other | An object to compare with |
Returns
Type | Description |
---|---|
System.Boolean |
|
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | if the Union<T1, T2> is not comparable |
GreaterThanOrEqual(Union<T1, T2>, Object)
Compares the current instance with another object of the same type.
Declaration
public static bool operator >=(Union<T1, T2> union, object other)
Parameters
Type | Name | Description |
---|---|---|
Union<T1, T2> | union | The Union<T1, T2> value |
System.Object | other | An object to compare with |
Returns
Type | Description |
---|---|
System.Boolean |
|
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | if the Union<T1, T2> is not comparable |
Implicit(T1 to Union<T1, T2>)
Converts a T1
value in a Union<T1, T2>
Declaration
public static implicit operator Union<T1, T2>(T1 value)
Parameters
Type | Name | Description |
---|---|---|
T1 | value | The |
Returns
Type | Description |
---|---|
Union<T1, T2> |
Implicit(T2 to Union<T1, T2>)
Converts a T2
value in a Union<T1, T2>
Declaration
public static implicit operator Union<T1, T2>(T2 value)
Parameters
Type | Name | Description |
---|---|---|
T2 | value | The |
Returns
Type | Description |
---|---|
Union<T1, T2> |
Implicit(Union<T1, T2> to T1)
Gets the T1
value
Declaration
public static implicit operator T1(Union<T1, T2> union)
Parameters
Type | Name | Description |
---|---|---|
Union<T1, T2> | union | A Union<T1, T2> value |
Returns
Type | Description |
---|---|
T1 |
Exceptions
Type | Condition |
---|---|
System.FieldAccessException | The union have not a |
Implicit(Union<T1, T2> to T2)
Gets the T2
value
Declaration
public static implicit operator T2(Union<T1, T2> union)
Parameters
Type | Name | Description |
---|---|---|
Union<T1, T2> | union | A Union<T1, T2> value |
Returns
Type | Description |
---|---|
T2 |
Exceptions
Type | Condition |
---|---|
System.FieldAccessException | The union have not a |
Inequality(Union<T1, T2>, Object)
Indicates whether the current object is not equal to another object of the same type.
Declaration
public static bool operator !=(Union<T1, T2> union, object other)
Parameters
Type | Name | Description |
---|---|---|
Union<T1, T2> | union | The Union<T1, T2> value |
System.Object | other | An object to compare with |
Returns
Type | Description |
---|---|
System.Boolean |
|
LessThan(Union<T1, T2>, Object)
Compares the current instance with another object of the same type.
Declaration
public static bool operator <(Union<T1, T2> union, object other)
Parameters
Type | Name | Description |
---|---|---|
Union<T1, T2> | union | The Union<T1, T2> value |
System.Object | other | An object to compare with |
Returns
Type | Description |
---|---|
System.Boolean |
|
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | if the Union<T1, T2> is not comparable |
LessThanOrEqual(Union<T1, T2>, Object)
Compares the current instance with another object of the same type.
Declaration
public static bool operator <=(Union<T1, T2> union, object other)
Parameters
Type | Name | Description |
---|---|---|
Union<T1, T2> | union | The Union<T1, T2> value |
System.Object | other | An object to compare with |
Returns
Type | Description |
---|---|
System.Boolean |
|
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | if the Union<T1, T2> is not comparable |