iStringExtensions 1.1.0

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

iStringExtensions

A C# library that provides a collection of useful string extension methods for common string manipulation and validation tasks. This library consolidates various string utility methods used across different projects into a single, reusable package.

Installation

You can install iStringExtensions via NuGet:

Install-Package iStringExtensions

Or using the .NET CLI:

dotnet add package iStringExtensions

Features

String Validation

  • IsInteger(): Check if a string represents a valid integer
  • IsNumber(): Check if a string represents a valid number (supports decimal numbers)
  • IsJson(): Validate if a string is valid JSON
  • IsEmail(): Validate email address format
  • IsIpV4(): Validate IPv4 address format

String Transformation

  • WrapWithAList(): Convert string to List<string>
  • WrapWithAnArray(): Convert string to string array
  • ConsolidateSpaces(): Replace multiple consecutive spaces with a single space
  • ToMemoryStream(): Convert string to MemoryStream

String Parsing

  • SplitAsEnumerableOf<T>(): Split string into enumerable of any primitive type
  • QueryStringToDictionary(): Parse query string into dictionary
  • RegexMatch(): Perform regex matching
  • RegexExtract(): Extract matches using regex

String Hashing

  • GetMd5Hash(): Generate MD5 hash of a string
  • GetSha1Hash(): Generate SHA1 hash of a string

JSON Handling

  • DeserializeJson<T>(): Deserialize JSON strings into objects

Usage Examples

using iStringExtensions;

// Validation examples
bool isInteger = "123".IsInteger(); // true
bool isNumber = "123.45".IsNumber(); // true
bool isValidJson = "{\"name\":\"test\"}".IsJson(); // true

// Transformation examples
List<string> list = "test".WrapWithAList();
string[] array = "test".WrapWithAnArray();

// Parsing examples
var numbers = "1,2,3".SplitAsEnumerableOf<int>(",");
var dictionary = "key1=value1;key2=value2".QueryStringToDictionary();

// Hashing examples
string md5 = "test".GetMd5Hash();
string sha1 = "test".GetSha1Hash();

Error Handling

The library includes robust error handling with a custom StringExtensionsException class that is thrown when validation fails or invalid operations are attempted.

Testing

The library includes comprehensive unit tests in the UnitTests project using xUnit and FluentAssertions.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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.

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
1.1.0 285 6/11/2025
1.0.1 233 6/18/2023
1.0.0 195 6/18/2023