IsEven 5.0.0
dotnet add package IsEven --version 5.0.0
NuGet\Install-Package IsEven -Version 5.0.0
<PackageReference Include="IsEven" Version="5.0.0" />
paket add IsEven --version 5.0.0
#r "nuget: IsEven, 5.0.0"
// Install IsEven as a Cake Addin #addin nuget:?package=IsEven&version=5.0.0 // Install IsEven as a Cake Tool #tool nuget:?package=IsEven&version=5.0.0
IsEven
A robust, extensible, and blue-sky-thinking .NET library for calculating if a number is even.
In a rapidly-changing technology landscape where the demystification of number even-ness is mission-critical, this may be the game-changer for facing into your organisational arithmetic delivery.
With the introduction of the .NET 7 INumber
interface that already offers IsEvenInteger
and IsOddInteger
out of the box, this library places you back in the box with an additional project dependency.
Examples
Use the IsEvenClient
to determine the even-ness of your number, using Modulo division by default:
IIsEvenClient isEvenClient = new IsEvenClient();
bool isEven = isEvenClient.IsEven(2);
bool isOdd = isEvenClient.IsOdd(5);
An AlgorithmType
argument may optionally be supplied to specify the algorithm to use when calculating whether a number is even:
bool isEven = isEvenClient.IsEven(2, AlgorithmType.LastDigitCheck);
Sometimes you may be unsure if you have a number that is odd or even - the below squares the circle, alleviating all doubt:
bool isOddOrEven = isEvenClient.IsOddOrEven(2);
Dependency Injection
You may also face into the strategic IIsEvenClient
interface, pivoting into dependency injection and mocking opportunities.
Here is an example of it being added to a DI container with the Microsoft.Extensions.DependencyInjection
library:
public static class Extensions
{
private static void AddIsEvenClient(this IServiceCollection services, IIsEvenClientSettings settings)
{
services.AddTransient<IIsEvenClient>(c =>
{
return new IsEvenClient(settings);
});
}
}
Dependencies
This library does not include dependencies to avoid additional architectural sign-off, keeping the discussions about introducing this library confined to only a handful of solution assessment boards.
Performance
This library has not been performance tested but ran quite quickly on Gareth's laptop.
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. |
-
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.