Struct Unit
A unit type that allows only one value and carries no information.
public readonly struct Unit
- Inherited Members
Examples
// Use Unit for operations that succeed without returning a value
Result<Unit> result = await client.DeleteRecordingAsync(recordingId);
result.Match(
success => Console.WriteLine("Deleted successfully"),
failure => Console.WriteLine($"Failed: {failure.GetFailureMessage()}")
);
Remarks
Unit is used as a return type when you need to indicate completion but have no value to return, similar to void but usable in generic contexts.
Commonly used with Result<T> when an operation succeeds but has no return value.
Fields
Default
The single Unit value. Use this when returning Unit.
public static readonly Unit Default