IsEven 5.0.0

dotnet add package IsEven --version 5.0.0                
NuGet\Install-Package IsEven -Version 5.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="IsEven" Version="5.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IsEven --version 5.0.0                
#r "nuget: IsEven, 5.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.
// 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 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. 
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
5.0.0 111 7/18/2024
4.0.0 170 9/27/2023
3.0.0 178 5/13/2023
2.0.0 436 8/18/2022
1.0.0 408 8/4/2022