AgileCoding.Extentions.Integer
2.0.5
dotnet add package AgileCoding.Extentions.Integer --version 2.0.5
NuGet\Install-Package AgileCoding.Extentions.Integer -Version 2.0.5
<PackageReference Include="AgileCoding.Extentions.Integer" Version="2.0.5" />
paket add AgileCoding.Extentions.Integer --version 2.0.5
#r "nuget: AgileCoding.Extentions.Integer, 2.0.5"
// Install AgileCoding.Extentions.Integer as a Cake Addin #addin nuget:?package=AgileCoding.Extentions.Integer&version=2.0.5 // Install AgileCoding.Extentions.Integer as a Cake Tool #tool nuget:?package=AgileCoding.Extentions.Integer&version=2.0.5
AgileCoding.Extensions.Integer
Overview
AgileCoding.Extensions.Integer is a .NET library that provides several useful extension methods related to integers. This package simplifies certain tasks related to integer conversion and validation.
Installation
This library is distributed via NuGet. To install it, use the NuGet package manager console:
bashCopy code
Install-Package AgileCoding.Extensions.Integer -Version 1.0.0
Features
This library introduces the following extension methods:
- ToInt: Converts a string to an integer. If the string cannot be converted, it returns 0.
- ToInt with Exception: Converts a string to an integer and throws a specific exception if the string cannot be converted.
- ThrowsIfTrue: Throws a specific exception if the given condition is true.
Usage
Here's an example of how to use these features in your code:
using AgileCoding.Extentions.Integers;
using System;
// Convert a string to an integer
int number1 = "123".ToInt();
// Convert a string to an integer and throw an exception if conversion fails
try
{
int number2 = "abc".ToInt<FormatException>("The input string was not in a correct format.");
}
catch (FormatException ex)
{
// Handle or log the exception...
}
// Throw an exception if a condition is true
try
{
int number3 = 10.ThrowsIfTrue<OverflowException>(number3 > int.MaxValue, "The number exceeds the maximum integer value.");
}
catch (OverflowException ex)
{
// Handle or log the exception...
}
Documentation
For more detailed information about the usage of this library, please refer to the official documentation.
License
This project is licensed under the terms of the MIT license. For more information, see the LICENSE file.
Contributing
Contributions are welcome! Please see our contributing guidelines for more details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
-
net6.0
- AgileCoding.Extentions.Activator (>= 2.0.5)
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 |
---|---|---|
2.0.5 | 190 | 7/31/2023 |
Cleanup un neede references