Skip to content

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

View source

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

NameSummary
.ctorInitializes a new instance of the [Result](# struct. Initializes a new instance of the Result class with the specified exception.

Properties

NameSummary
static SuccessGets a predefined result instance that indicates a successful operation.
ExceptionGets the exception that caused the current operation to fail, if any.
IsSuccessGets a value indicating whether the operation completed successfully without an exception.
IsFailureGets a value indicating whether the operation has failed.

Methods

NameSummary
static FailureCreates a failed result that encapsulates the specified exception.
TryThrowThrows the associated exception if the result represents a failure.
ToStringReturns a string that represents the result status of the operation.
GetHashCode
Equals

Operators

NameSummary
static op_Inequality
static op_Equality