Table of Contents

Class Optional<T>

Namespace
DotTiled
Assembly
DotTiled.dll

Represents a value that may or may not be present.

public class Optional<T>

Type Parameters

T

The type of the optionally present value.

Inheritance
Optional<T>
Inherited Members

Constructors

Optional()

Initializes a new instance of the Optional<T> class with no value.

public Optional()

Optional(T)

Initializes a new instance of the Optional<T> class with the specified value.

public Optional(T value)

Parameters

value T

The value to be set.

Properties

Empty

Represents an empty Optional<T> object.

public static Optional<T> Empty { get; }

Property Value

Optional<T>

HasValue

Gets a value indicating whether the current Optional<T> object has a value.

public bool HasValue { get; }

Property Value

bool

Value

Gets the value of the current Optional<T> object if it has been set; otherwise, throws an exception.

public T Value { get; }

Property Value

T

Methods

Equals(object)

Determines whether the specified object is equal to the current object.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

GetValueOr(T)

Returns the value of the current Optional<T> object if it has been set; otherwise, returns the specified default value.

public T GetValueOr(T defaultValue)

Parameters

defaultValue T

The value to be returned if the current Optional<T> object has no value.

Returns

T

GetValueOrOptional(Optional<T>)

Returns the current Optional<T> object if it has a value; otherwise, returns the specified default value.

public Optional<T> GetValueOrOptional(Optional<T> defaultValue)

Parameters

defaultValue Optional<T>

The Optional<T> object to be returned if the current Optional<T> object has no value.

Returns

Optional<T>

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

Operators

operator ==(Optional<T>, Optional<T>)

Determines whether the specified Optional<T> objects are equal.

public static bool operator ==(Optional<T> left, Optional<T> right)

Parameters

left Optional<T>
right Optional<T>

Returns

bool

implicit operator T(Optional<T>)

Implicitly converts an Optional<T> object to a value.

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

Parameters

optional Optional<T>

The Optional<T> object to be converted.

Returns

T

implicit operator Optional<T>(T)

Implicitly converts a value to an Optional<T> object.

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

Parameters

value T

The value to be converted.

Returns

Optional<T>

operator !=(Optional<T>, Optional<T>)

Determines whether the specified Optional<T> objects are not equal.

public static bool operator !=(Optional<T> left, Optional<T> right)

Parameters

left Optional<T>
right Optional<T>

Returns

bool