New paste Use cases Explore public pastes Text tools Developer API The Paste Library Security Sign in with Google
CSHARPExample pasteCreated 2026-07-312 viewsNo expiry

C# result type for service operations

Raw New paste
csharpRead-only
1
public sealed record Result<T>(T? Value, string? Error)
{
    public bool IsSuccess => Error is null;

    public static Result<T> Success(T value) => new(value, null);
    public static Result<T> Failure(string error) => new(default, error);
}

var result = Result<int>.Success(42);
Console.WriteLine(result.IsSuccess ? result.Value : result.Error);
Report abuse

Paste details

Visibility
Public
Size
350 bytes
Protection
Standard link access
Retention
No automatic expiry

Share with confidence

Unlisted links are not searchable, but anyone with the URL can open them. Never paste live credentials or personal data.