Kaz.Operations
1.2.0
Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
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" />
<PackageReference Include="Kaz.Operations" />
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
#tool nuget:?package=Kaz.Operations&version=1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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.TextString editing and manipulation:
Reverse
string example = "abc"; string reversed = example.Reverse(); // cbaRemoveWhiteSpaces
string example = "a b c"; string noWhiteSpaces = example.RemoveWhiteSpaces(); // abcExtractAllNumbers
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); // HUIf 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(); // trueIsEmail
string example = "example@gmail.com"; bool isEmail = example.IsEmail(); // true string example1 = "@hi.gmail.com".IsEmail(); bool isEmail1 = example.IsEmail(); // falseIsPhoneNumber
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.NumericsSafe 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); // 5CalculatePercentage<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); // 200Lerp (+2 overloads)
// Also supports overloads for float and decimal double example = 15; Console.WriteLine(example.Lerp(16, 0.5)); // 15.5
Kaz.Operations.CollectionsSorting 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 propertyBubbleSort
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:
BubbleSortandSelectionSortare 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
Links
| Product | Versions 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.
-
.NETFramework 4.7.2
- Kaz.Operations.Core (>= 1.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.