MyResults 1.0.0
dotnet add package MyResults --version 1.0.0
NuGet\Install-Package MyResults -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MyResults" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MyResults" Version="1.0.0" />
<PackageReference Include="MyResults" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MyResults --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MyResults, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MyResults@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MyResults&version=1.0.0
#tool nuget:?package=MyResults&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MyResultPackage
Basic result nuget package structure for APIs
Structure
MyResultPackage is a NuGet package designed to simplify creating a standardized and consistent result structure for APIs.
With this package, you can manage success, error, data, and their message combinations in a type-safe and readable way.
Scenario | Class to Use |
---|---|
Return only an error state with a message | ErrorResult |
Return only a success state with a message | SuccessResult |
Return data + error state + message | ErrorDataResult<T> |
Return data + success state + message | SuccessDataResult<T> |
Installation
dotnet add package MyResults --version 1.0.0
Usage Success
public class Product
{
public int Id { get; set; }
public string Description { get; set; }
}
using MyResults;
namespace ConsoleApp1
{
public class Class1
{
public static void Main()
{
Product prod = new Product
{
Id = 1,
Description = "A product"
};
var dataResult = new DataResult<Product>(prod, true, "Product found");
if (dataResult.Success)
{
Console.WriteLine(dataResult.Message);
Console.WriteLine($"Product ID: {dataResult.Data.Id}");
Console.WriteLine($"Product Description: {dataResult.Data.Description}");
}
Console.ReadLine();
}
}
}
Usage Error
using MyResults;
namespace ConsoleApp1
{
public class Class1
{
public static void Main() {
var dataResult = new DataResult<Product>(new Product(), false, "Product not found");
if (dataResult.Success)
{
Console.WriteLine(dataResult.Message);
Console.WriteLine($"Product ID: {dataResult.Data.Id}");
Console.WriteLine($"Product Description: {dataResult.Data.Description}");
}
else
{
Console.WriteLine("Error: " + dataResult.Message);
}
Console.ReadLine();
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.0 | 139 | 8/13/2025 |