FunctionalStringExtensions 1.0.5
dotnet add package FunctionalStringExtensions --version 1.0.5
NuGet\Install-Package FunctionalStringExtensions -Version 1.0.5
<PackageReference Include="FunctionalStringExtensions" Version="1.0.5" />
<PackageVersion Include="FunctionalStringExtensions" Version="1.0.5" />
<PackageReference Include="FunctionalStringExtensions" />
paket add FunctionalStringExtensions --version 1.0.5
#r "nuget: FunctionalStringExtensions, 1.0.5"
#:package FunctionalStringExtensions@1.0.5
#addin nuget:?package=FunctionalStringExtensions&version=1.0.5
#tool nuget:?package=FunctionalStringExtensions&version=1.0.5
🧶 FunctionalStringExtensions
FunctionalStringExtensions
is a C# class library that provides a set of extension methods for working with strings.
These extensions are designed to make common string manipulation tasks more convenient and expressive.
Whether you're dealing with default values, asynchronous operations, or executing actions based on string conditions,
these extensions aim to simplify your code and enhance its readability.
Installation 🚀
To easily integrate the FunctionalStringExtensions library into your project, you can use NuGet Package Manager. NuGet is a package manager for .NET that simplifies the process of adding, removing, and updating libraries in your applications.
After that import the FunctionalStringExtensions
namespace in your code files where you want to use the provided extension methods:
using FunctionalStringExtensions;
Available Extension Methods 🛠️
OrDefault
This extension method returns the provided default value if the input string is null or empty.
Usage:
string result = input.OrDefault("default value");
OrDefaultAsync
Similar to the OrDefault
method, this asynchronous extension returns a default value obtained from a Task<string>
if the input string is null or empty.
Usage:
string result = await input.OrDefaultAsync(Task.FromResult("default value"));
WhenNullOrEmpty
This extension method returns the result of the provided delegate function if the input string is null or empty.
Usage:
string result = input.WhenNullOrEmpty(() => "default value");
WhenNullOrEmptyAsync
Similar to the WhenNullOrEmpty
method, this asynchronous extension returns a value obtained from a Task<string>
returned by the delegate function if the input string is null or empty.
Usage:
string result = await input.WhenNullOrEmptyAsync(async () => await GetDefaultValueAsync());
OnNullOrEmpty
This extension method executes the provided action if the input string is null or empty.
Usage:
input.OnNullOrEmpty(() => Console.WriteLine("Input is null or empty."));
OnNullOrEmptyAsync
Similar to the OnNullOrEmpty
method, this asynchronous extension executes a provided task if the input string is null or empty.
Usage:
await input.OnNullOrEmptyAsync(async () => await PerformAsyncAction());
ToSlug
Turns your string in a slug
Usage
var slug = "ICH MUß EINIGE CRÈME BRÛLÉE HABEN".ToSlug();
ToEnum
Parse your string to a Enum value
Usage
public enum FakeEnum
{
Value1,
Value2
}
var result = "Value1".ToEnum<FakeEnum>(); // FakeEnum.Value1
OnlyLetters
Search for letters (A to Z) in the string
Usage
var result = "abc123def456ghi".OnlyLetters(); //"abcdefghi"
OnlyNumbers
Search for numbers (0 to 9) in the string
Usage
var result = "abc123def456ghi".OnlyNumbers(); //"123456"
OnlyCharactersAndNumbers
Search for characters and numbers (A to Z or 0 to 9) in the string
Usage
var result = "12.8/0';@#!%^&*()a12,9abc".OnlyCharactersAndNumbers(); //"1280a129abc"
OnlySpecialCharacters
Search for especial characters (not A to Z and not 0 to 9) in the string
Usage
var result = "12.8/0';@#!%^&*()a12,9abc".OnlySpecialCharacters(); //"./';@#!%^&*(),"
ParseQueryString
Parses a query string into a dictionary of key-value pairs.
Usage
var queryString = "?name=JohnDoe&age=30&isMember=true";
var result = queryString.ParseQueryString(autoConvertType: true);
// result will be a dictionary with keys "name", "age", "isMember"
// and corresponding values "JohnDoe", 30, true
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- 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.