Summary
An optional typed value.
- Namespace
- Avalonia
.Data - Interfaces
- Base Types
-
- object
- ValueType
graph BT
Type-->Base0["ValueType"]
Base0-->Base1["object"]
Type-.->Interface0["IEquatable<Optional<T>>"]
Type["Optional<T>"]
class Type type-node
Syntax
public readonly struct Optional<T> : ValueType, IEquatable<Optional<T>>
Remarks
This struct is similar to
System.Nullable`1
except it also accepts reference types:
note that null is a valid value for reference types. It is also similar to
BindingValue<T>
but has only two states: "value present" and "value missing".
To create a new optional value you can:
- For a simple value, call the Optional<T>
constructor or use an implicit
conversion from T
- For an missing value, use Empty
or simply `default`
Type Parameters
Name | Description |
---|---|
T | The value type. |
Constructors
Name | Summary |
---|---|
Optional |
Initializes a new instance of the Optional<T> struct with value.
|
Properties
Methods
Name | Value | Summary |
---|---|---|
Equals |
bool | |
Equals |
bool | |
GetHashCode |
int | |
GetValueOrDefault |
T |
Gets the value if present, otherwise the default value.
|
GetValueOrDefault |
T |
Gets the value if present, otherwise a default value.
|
GetValueOrDefault |
TResult |
Gets the value if present, otherwise the default value.
|
GetValueOrDefault |
TResult |
Gets the value if present, otherwise a default value.
|
ToObject |
Optional |
Casts the value (if any) to an
object .
|
ToString |
string |