Alefair.Extended.Methods 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Alefair.Extended.Methods --version 1.0.1                
NuGet\Install-Package Alefair.Extended.Methods -Version 1.0.1                
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="Alefair.Extended.Methods" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Alefair.Extended.Methods --version 1.0.1                
#r "nuget: Alefair.Extended.Methods, 1.0.1"                
#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.
// Install Alefair.Extended.Methods as a Cake Addin
#addin nuget:?package=Alefair.Extended.Methods&version=1.0.1

// Install Alefair.Extended.Methods as a Cake Tool
#tool nuget:?package=Alefair.Extended.Methods&version=1.0.1                

Alefair.Extended.Methods

Extended Methods powered by Alefair

Current version 1.0.1

nuget on https://www.nuget.org

class StringExtended

Methods:


Like
/// <summary>
/// "String".Like("*ring*") -> true
/// </summary>
/// <param name="toSearch"></param>
/// <param name="toFind"></param>
/// <param name="RegOptions"></param>
/// <returns></returns>
public static bool Like(this string toSearch, string toFind, RegexOptions RegOptions = RegexOptions.IgnoreCase)

"123 456 789".Like("456") - > true
"123 456 789".Like("^456") -> false

ContainsInList
/// <summary>
/// "Hello, world!".ContainsInList(new List(){"world", "peace", "men"}) -> true
/// </summary>
/// <param name="toSearch"></param>
/// <param name="currentList"></param>
/// <returns></returns>
public static bool ContainsInList(this string toSearch, List<string> currentList = default(List<string>))

"123 456 789".ContainsInList({"asd", "456", "ghj"})  - > true
"123 456 789".ContainsInList({"asd", "^456", "ghj"}) - > false

ToDouble
/// <summary>
/// "0,13".ToDouble() -> 0.13
/// "0,13".ToDouble(3) -> 0.130
/// </summary>
/// <param name="cdblString"></param>
/// <param name="Count"></param>
/// <returns></returns>
public static double ToDouble(this string cdblString, int Count = -1)

"123 456 789".ToDouble()         -> 123456789
"123 456 789.123456".ToDouble(2) -> 12346789.12

ToDoubleStr
/// <summary>
/// "0,13".ToDoubleStr() -> "0.13"
/// "0,13".ToDoubleStr("#.###") -> "0.130"
/// </summary>
/// <param name="cdblString"></param>
/// <param name="StringFormat"></param>
/// <returns></returns>
public static string ToDoubleStr(this string cdblString, string StringFormat = "*")

"123 456 789".ToDoubleStr()               -> "123456789"
"123 456 789.123456".ToDoubleStr("#.###") -> "123456789.123"

ToDecimal
/// <summary>
/// "0,13".ToDecimal() -> 0.13
/// "0,13".ToDecimal(3) -> 0.130
/// </summary>
/// <param name="decString"></param>
/// <param name="Count"></param>
/// <returns></returns>
public static decimal ToDecimal(this string decString, int Count = -1)

"123 456 789".ToDecimal()         -> 123456789
"123 456 789.123456".ToDecimal(2) -> 12346789.12

ToDecimalStr
/// <summary>
/// "0,13".ToDecimalStr() -> "0.13"
/// "0,13".ToDecimalStr("#.###") -> "0.130"
/// </summary>
/// <param name="decString"></param>
/// <param name="StringFormat"></param>
/// <returns></returns>
public static string ToDecimalStr(this string decString, string StringFormat = "*")

"123 456 789".ToDecimalStr()               -> "123456789"
"123 456 789.123456".ToDecimalStr("#.###") -> "123456789.123"

GetSimilarity
/// <summary>
/// "hello, world".GetSimilarity("hello,men") -> 0.58 is percent accuracy
/// </summary>
/// <param name="toSearch"></param>
/// <param name="toFind"></param>
/// <returns></returns>
public static Single GetSimilarity(this string toSearch, string toFind)

"123 456 789".GetSimilarity("123456 789") -> 0.9090909 - 91% accuracy
"123 456 789".GetSimilarity("123456789")  -> 0.8181818 - 82% accuracy

DictToString
/// <summary>
/// dict.DictToString() -> {"4"="a","5"="b"}
/// </summary>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
/// <param name="dictionary"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static string DictToString<TKey, TValue>(this IDictionary<TKey, TValue> dictionary)

(new Dictionary<string, object>() {{"a","1"}, {"b", 1}}).DictToString ->  "{\"a\"=\"1\",\"b\"=\"1\"}"

DictToJson
/// <summary>
/// dict.DictToJson() -> {4:"a", 5:"b"}
/// </summary>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
/// <param name="dictionary"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static JObject DictToJson<TKey, TValue>(this IDictionary<TKey, TValue> dictionary)

(new Dictionary<string, object>() {{"a","1"}, {"b", 1}}).DictToJson ->  {"a":"1","b"=1}

DateParse
/// <summary>
/// "10.07.2022".DateParse() -> 07/10/2022 00:00:00
/// </summary>
/// <param name="date"></param>
/// <param name="listFormat"></param>
/// <returns></returns>
public static DateTime DateParse(this string date, string[] listFormat = null)

"10.07.2022".DateParse()                                     -> 07/10/2022 00:00:00
"7/10/22".DateParse({"M/dd/yy", "dd.MM.yyyy", "MM/dd/yyyy"}) -> 07/10/2022 00:00:00
Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has 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
1.0.12 363 12/28/2022
1.0.6 447 9/20/2022
1.0.5 418 9/20/2022
1.0.4 693 9/18/2022
1.0.3 411 9/8/2022
1.0.1 428 8/20/2022