Show / Hide Table of Contents

# Struct Optional<T>

##### Inherited Members

System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()

###### Namespace: Discord

###### Assembly: Discord.Net.Core.dll

##### Syntax

    public struct Optional<T>

##### Type Parameters

Name | Description
--- | ---
T |

### Constructors

| Improve this Doc View Source

#### Optional(T)

Creates a new Parameter with the provided value.

##### Declaration

    public Optional(T value)

##### Parameters

Type | Name | Description
--- | --- | ---
T | value |

### Properties

| Improve this Doc View Source

#### IsSpecified

Returns true if this value has been specified.

##### Declaration

    public bool IsSpecified { get; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### Unspecified

##### Declaration

    public static Optional<T> Unspecified { get; }

##### Property Value

Type | Description
--- | ---
Optional<T> |

| Improve this Doc View Source

#### Value

Gets the value for this parameter.

##### Declaration

    public T Value { get; }

##### Property Value

Type | Description
--- | ---
T |

##### Exceptions

Type | Condition
--- | ---
System.InvalidOperationException | This property has no value set.

### Methods

| Improve this Doc View Source

#### Equals(Object)

##### Declaration

    public override bool Equals(object other)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Object | other |

##### Returns

Type | Description
--- | ---
System.Boolean |

##### Overrides

System.ValueType.Equals(System.Object)
| Improve this Doc View Source

#### GetHashCode()

##### Declaration

    public override int GetHashCode()

##### Returns

Type | Description
--- | ---
System.Int32 |

##### Overrides

System.ValueType.GetHashCode()
| Improve this Doc View Source

#### GetValueOrDefault()

##### Declaration

    public T GetValueOrDefault()

##### Returns

Type | Description
--- | ---
T |

| Improve this Doc View Source

#### GetValueOrDefault(T)

##### Declaration

    public T GetValueOrDefault(T defaultValue)

##### Parameters

Type | Name | Description
--- | --- | ---
T | defaultValue |

##### Returns

Type | Description
--- | ---
T |

| Improve this Doc View Source

#### ToString()

##### Declaration

    public override string ToString()

##### Returns

Type | Description
--- | ---
System.String |

##### Overrides

System.ValueType.ToString()

### Operators

| Improve this Doc View Source

#### Explicit(Optional<T> to T)

##### Declaration

    public static explicit operator T(Optional<T> value)

##### Parameters

Type | Name | Description
--- | --- | ---
Optional<T> | value |

##### Returns

Type | Description
--- | ---
T |

| Improve this Doc View Source

#### Implicit(T to Optional<T>)

##### Declaration

    public static implicit operator Optional<T>(T value)

##### Parameters

Type | Name | Description
--- | --- | ---
T | value |

##### Returns

Type | Description
--- | ---
Optional<T> |