Class StringExtensions
- Namespace
- NuvTools.Common.Strings
- Assembly
- NuvTools.Common.dll
public static class StringExtensions
- Inheritance
-
StringExtensions
- Inherited Members
Methods
Format(string, Dictionary<string, object?>, IFormatProvider?)
Replaces the format item in a specified string with the string representation of a corresponding object by the key in the Dictionary.
public static string Format(this string template, Dictionary<string, object?> args, IFormatProvider? provider = null)
Parameters
templatestringA composite format string.
argsDictionary<string, object>A Dictionary that contains zero or more values to format by the key.
providerIFormatProviderAn object that supplies culture-specific formatting information.
Returns
- string
A copy of format in which the format items have been replaced by the string representation of the corresponding values in Dictionary.
Exceptions
Format(string, IFormatProvider?, params object?[])
Replaces the format item in a specified string with the string representation of a corresponding object by the key in the Dictionary.
public static string Format(this string template, IFormatProvider? provider, params object?[] args)
Parameters
templatestringA composite format string.
providerIFormatProviderAn object that supplies culture-specific formatting information.
argsobject[]A string array that contains zero or more objects to format.
Returns
- string
A copy of format in which the format items have been replaced by the string representation of the corresponding strings in args.
Exceptions
Format(string, params object?[])
Replaces the format item in a specified string with the string representation of a corresponding object by the key in the Dictionary.
public static string Format(this string template, params object?[] args)
Parameters
templatestringA composite format string.
argsobject[]A string array that contains zero or more objects to format.
Returns
- string
A copy of format in which the format items have been replaced by the string representation of the corresponding strings in args.
Exceptions
FormatJson(string)
Format the string to pretty-format Json.
public static string FormatJson(this string value)
Parameters
valuestringJson content.
Returns
GetNumbersOnly(string)
Extracts only the numeric digits from a string, removing all non-digit characters.
public static string GetNumbersOnly(this string value)
Parameters
valuestringThe string to process.
Returns
- string
A string containing only the numeric digits from the input.
IsValidJson(string)
Checks whether the text is a valid Json.
public static bool IsValidJson(this string value)
Parameters
valuestring
Returns
Left(string?, int)
Gets the first characters from string.
public static string? Left(this string? value, int length)
Parameters
valuestringString that contains the characters to be extracted.
lengthintThe number of characters to be extracted.
Returns
Exceptions
RemoveDiacritics(string?)
public static string? RemoveDiacritics(this string? value)
Parameters
valuestringThe text with sign, accent or cedill to remove.
Returns
RemoveSpecialCharacters(string?)
Removes the special characters from text.
public static string? RemoveSpecialCharacters(this string? value)
Parameters
valuestringText content.
Returns
Right(string?, int)
Gets the last characters from string.
public static string? Right(this string? value, int length)
Parameters
valuestringString that contains the characters to be extracted.
lengthintThe number of characters to be extracted.