You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 29, 2024. It is now read-only.
Sascha Manns edited this page Sep 6, 2024
·
1 revision
Result
This class can be used for using the result pattern.
Usage
publicResult<string>GetUserNameById(intuserId){if(userId<=0){returnResult<string>.Failure("Invalid user ID");}// We simulate obtaining a usernamestringuserName="John Doe";// This would be the actual logic to get the namereturnResult<string>.Success(userName);}publicvoidProcessUserName(){varresult=GetUserNameById(1);if(result.IsSuccess){Console.WriteLine($"User name: {result.Value}");}else{Console.WriteLine($"Error: {result.ErrorMessage}");}}