Kaz.Operations 1.2.0

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Kaz.Operations --version 1.2.0
                    
NuGet\Install-Package Kaz.Operations -Version 1.2.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="Kaz.Operations" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Kaz.Operations" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Kaz.Operations" />
                    
Project file
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 Kaz.Operations --version 1.2.0
                    
#r "nuget: Kaz.Operations, 1.2.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 Kaz.Operations@1.2.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=Kaz.Operations&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Kaz.Operations&version=1.2.0
                    
Install as a Cake Tool

Kaz.Operations

A set of utilities for working with strings, numeric conversions, and collections. The package extends the standard capabilities of .NET and provides a unified API for basic operations.

Dependency: Kaz.Operations.Core


Possibilities


  • Kaz.Operations.Text

    • String editing and manipulation:
      • Reverse

      string example = "abc";
      string reversed = example.Reverse(); // cba
      
      • RemoveWhiteSpaces

       string example = "a b c";
       string noWhiteSpaces = example.RemoveWhiteSpaces(); // abc
      
      • ExtractAllNumbers

      string example = "a1b2c";
      var digits = input.ExtractAllNumbers(NumberExtractionOptions.Digits); // 1, 2 (List<string>)
      
      • ExtractPattern

      Regex regex = new Regex(@"[A-Z]");
      string example = "Hello User!".ExtractPattern(regex); // HU
      
    • If Regex is null, an exception will be thrown:
      string example = "Hello User!".ExtractPattern(null); // Throws ArgumentNullException
      

    • Checking strings for format compliance:
      • IsNumeric

      string example = "123";
      bool isNumeric= example.IsNumeric(); // true
      
      • IsEmail

      string example = "example@gmail.com";
      bool isEmail = example.IsEmail(); // true
      
      string example1 = "@hi.gmail.com".IsEmail(); 
      bool isEmail1 = example.IsEmail(); // false
      
      • IsPhoneNumber

      string example = "+442079460000"; // only supports E.164 format
      bool isPhoneNumber = example.IsPhoneNumber(); // true
      
      string example1 = "+012345"; 
      bool isPhoneNumber1 = example1.IsPhoneNumber(); // false
      
      • A bunch of other cool methods!

  • Kaz.Operations.Numerics

    • Safe conversion of string values into numeric types:
      • ToNumericOrDefault<T>

      // Supported types: int, long, float, double, decimal, short, byte.
      
      string example = "123";
      int number = example.ToNumericOrDefault<int>(0); // 123
      
      string invalidExample = "invalid";
      int fallback = invalidExample.ToNumericOrDefault<int>(0); // 0 (Specified default value)
      
      string example1 = "19.99";
      double price = example1.ToNumericOrDefault<double>(0.0); // 19.99
      

    • Math operations:
      • Clamp<T>

      int number = 10;
      int result = number.Clamp(0, 5); // 5
      
      • CalculatePercentage<T>

      double number = 500;
      
      // FractionOfTotal (Calculates 10% of 500)
      double result = number.CalculatePercentage(10, PercentageCalculationMethod.FractionOfTotal); // 50
      
      double number1 = 1000m;
      
      // RatioOfTotal (Calculates percentage ratio)
      decimal total = number1.CalculatePercentage(20, PercentageCalculationMethod.RatioOfTotal); // 200
      
      • Lerp (+2 overloads)

      // Also supports overloads for float and decimal
      
      double example = 15;
      Console.WriteLine(example.Lerp(16, 0.5)); // 15.5
      

  • Kaz.Operations.Collections

    • Sorting IList collections:
      • MergeSort

      var items = new List<int> { 5, 3, 8, 1 };
      items.MergeSort(); // [1, 3, 5, 8]
      
      • CountingSort

      var users = new List<User> 
      { 
          new User { Id = 103, Name = "Alice" },
          new User { Id = 101, Name = "Bob" }
      };
      users.CountingSort(u => u.Id); // Sorted by Id property
      
      • BubbleSort

      int[] list = {3, 2, 1};
      list.BubbleSort(); // [1, 2, 3]
      
      • SelectionSort

      int[] list = {3, 2, 1};
      list.SelectionSort(); // [1, 2, 3]
      

    • Searching through IList collections:
      • LinearSearch

      var list = {1, 2, 3};
      int index = list.LinearSearch(2); // 1 
      
      • Other searching methods!

    • Note: BubbleSort and SelectionSort are marked as deprecated and are not recommended for use (for educational purposes only).

Installation

  • .NET CLI:
dotnet add package Kaz.Operations
  • NuGet Package Manager:
Install-Package Kaz.Operations

Product Compatible and additional computed target framework versions.
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.0 80 3/20/2026
2.0.0-preview 76 3/19/2026
1.2.0 109 2/26/2026
1.1.12 88 2/24/2026
1.0.12 90 2/21/2026
1.0.11 91 2/21/2026
1.0.1 89 2/21/2026
1.0.0 86 2/21/2026