Unit Struct
Definition
- Namespace
- Tyne
- Assembly
- Tyne.Core.dll
The Unit type is a type that indicates the absence of a specific value; the Unit type has only a single value, which acts as a placeholder when no other value exists or is needed. Represents void since that is not a valid Type in C#.
public readonly struct Unit : IEquatable<Unit>, IComparable<Unit>, IComparable
- Implements
Remarks
Useful to normalise APIs, especially when using generic types.
For example, consider designing an API surface with a method that optionally takes a TIn
, and optionally returns a TOut
.
Constructors
Unit() | Creates a new Unit. |
Properties
AsTask | A Task<TResult> whose result is Value. |
AsValueTask | Creates a ValueTask<TResult> whose result is Value. |
Value | The default and only value of Unit. |
Methods
CompareTo(object?) | Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object. |
CompareTo(Unit) | Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object. |
Equals(object?) | Determines whether the specified |
Equals(Unit) | Determines whether the specified |
GetHashCode() | Returns a hash code for this instance. |
ToString() | Returns a string that represents this instance. |
Operators
operator ==(Unit, Unit) | Determines whether Units are equal. |
operator >(Unit, Unit) | |
operator >=(Unit, Unit) | Determines whether one Units is greater than or equal to another Unit. |
implicit operator Task<Unit>(Unit) | Implicitly returns a Task<TResult> whose result is Value. |
implicit operator ValueTask<Unit>(Unit) | Implicitly creates a ValueTask<TResult> whose result is Value. |
operator !=(Unit, Unit) | Determines whether Units are not equal. |
operator <(Unit, Unit) | |
operator <=(Unit, Unit) | Determines whether one Units is less than or equal to another Unit. |