Result struct¶
Attributes: [DebuggerDisplay("IsSuccess = {IsSuccess}, Exception = {Exception}")]
Defined in
Namespace: ReactiveUI.Primitives
Assembly: ReactiveUI.Primitives.Core.dll
Full name: ReactiveUI.Primitives.Result
Modifiers: public sealed
Summary¶
Represents the outcome of an operation, indicating success or failure and providing error details when applicable.
Applies to
net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, net462, net481
Class hierarchy
classDiagram
class Result
class IEquatable~Result~ {
<>
}
IEquatable~Result~ <|.. Result
Implements: IEquatable
Remarks¶
The Result struct is used to encapsulate the result of an operation, including whether it succeeded and, if not, the exception that caused the failure. Use the Success property for successful results and Failure to create failed results. The IsSuccess and IsFailure properties allow callers to check the operation's status before accessing error information or propagating exceptions. This struct is immutable and thread-safe.
Constructors¶
| Name | Summary |
|---|---|
| .ctor | Initializes a new instance of the [Result](# struct. Initializes a new instance of the Result class with the specified exception. |
Properties¶
| Name | Summary |
|---|---|
| static Success | Gets a predefined result instance that indicates a successful operation. |
| Exception | Gets the exception that caused the current operation to fail, if any. |
| IsSuccess | Gets a value indicating whether the operation completed successfully without an exception. |
| IsFailure | Gets a value indicating whether the operation has failed. |
Methods¶
| Name | Summary |
|---|---|
| static Failure | Creates a failed result that encapsulates the specified exception. |
| TryThrow | Throws the associated exception if the result represents a failure. |
| ToString | Returns a string that represents the result status of the operation. |
| GetHashCode | |
| Equals |
Operators¶
| Name | Summary |
|---|---|
| static op_Inequality | |
| static op_Equality |