Zhomfr.Helpers.ScalarTypes 0.1.0

dotnet add package Zhomfr.Helpers.ScalarTypes --version 0.1.0
                    
NuGet\Install-Package Zhomfr.Helpers.ScalarTypes -Version 0.1.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="Zhomfr.Helpers.ScalarTypes" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Zhomfr.Helpers.ScalarTypes" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Zhomfr.Helpers.ScalarTypes" />
                    
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 Zhomfr.Helpers.ScalarTypes --version 0.1.0
                    
#r "nuget: Zhomfr.Helpers.ScalarTypes, 0.1.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 Zhomfr.Helpers.ScalarTypes@0.1.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=Zhomfr.Helpers.ScalarTypes&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Zhomfr.Helpers.ScalarTypes&version=0.1.0
                    
Install as a Cake Tool

Helpers for scalar types

A collection of convenient and productive extension methods for primitive types in C# (string and decimal), designed to simplify everyday data processing and formatting tasks.

📦 Installation

Add the extension files to your project in the appropriate namespaces (Zhomfr.Helpers.ScalarTypes and Zhomfr.Helpers.ScalarTypes.Strings).


🛠️ Features and Examples

1. String Modification (ModificationExtensions)

This module provides methods for changing case, cleaning, masking, replacing, and formatting strings.

Mask (Masking Sensitive Data)

Ideal for hiding parts of email addresses, phone numbers, or credit card numbers.

string phone = "+380991234567";
string masked = phone.Mask(4, -4, '*'); // Result: "+380********4567"

Case and Identifier Styles (ToSnakeCase, ToCamelCase, ToPascalCase, ToKebabCase)
string text = "HelloWorld";

string snake = text.ToSnakeCase();   // "hello_world"
string kebab = text.ToKebabCase();   // "hello-world"
string camel = "hello_world".ToCamelCase(); // "helloWorld"
string pascal = "hello_world".ToPascalCase(); // "HelloWorld"

ChopStart / ChopEnd

Removes specific prefixes or suffixes from a string.

string filename = "prefix_data_suffix.txt";
string clean = filename.ChopStart("prefix_").ChopEnd(".txt"); // "data_suffix"

Squish and Deduplicate

Removes extraneous whitespace (similar to SQL TRIM or Laravel's Str::squish).

string messy = "   Hello    world!   ";
string clean = messy.Squish(); // "Hello world!"

Excerpt

Extracts a fragment around a search term with an omission indicator.

string article = "This is a long article text where we search for a keyword for context.";
string excerpt = article.Excerpt("keyword", radius: 10); 
// Result: "...text where we search for a keyword for..."


2. Substrings (SubstringsExtensions)

Methods for searching, trimming, and extracting text fragments.

After / Before
string path = "api/v1/users";
string after = path.After("api/");   // "v1/users"
string before = path.Before("/users"); // "api/v1"

Between

Extracts text between two markers.

string html = "<div>Hello, Oleg</div>";
string name = html.Between("<div>", "</div>"); // "Hello, Oleg"

Limit

Truncates a string to a specified length with optional whole word preservation.

string sentence = "This text is way too long to display.";
string shortText = sentence.Limit(18, "...", preserveWords: true); 
// Result: "This text ..."


3. General String Utilities (OtherExtensions)

Useful functions for analysis and counting.

WordCount and SubstringCount
string phrase = "Cat eats fish, cat sleeps.";
int words = phrase.WordCount();          // 5
int count = phrase.SubstringCount("cat"); // 2 (case-dependent)

Initials

Generates initials from a full name.

string fullName = "Oleg Ivanov";
string initials = fullName.Initials(); // "OI"


4. Decimal Extensions (DecimalExtensions)

Helper methods for working with decimal floating-point numbers.

decimal price = 1234.56m;

int intDigits = price.GetDigitsBeforeSeparator(); // 4
int totalDigits = price.GetDigits();              // 6


📄 License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.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
0.1.0 110 8/15/2026