Table of Contents

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

template string

A composite format string.

args Dictionary<string, object>

A Dictionary that contains zero or more values to format by the key.

provider IFormatProvider

An 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

ArgumentNullException

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

template string

A composite format string.

provider IFormatProvider

An object that supplies culture-specific formatting information.

args object[]

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

ArgumentNullException

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

template string

A composite format string.

args object[]

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

ArgumentNullException

FormatJson(string)

Format the string to pretty-format Json.

public static string FormatJson(this string value)

Parameters

value string

Json content.

Returns

string

GetNumbersOnly(string)

Extracts only the numeric digits from a string, removing all non-digit characters.

public static string GetNumbersOnly(this string value)

Parameters

value string

The 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

value string

Returns

bool

Left(string?, int)

Gets the first characters from string.

public static string? Left(this string? value, int length)

Parameters

value string

String that contains the characters to be extracted.

length int

The number of characters to be extracted.

Returns

string

Exceptions

ArgumentNullException

RemoveDiacritics(string?)

Remove a sign, such as an accent or cedill.

By Blair Conrad

See also here.

public static string? RemoveDiacritics(this string? value)

Parameters

value string

The text with sign, accent or cedill to remove.

Returns

string

RemoveSpecialCharacters(string?)

Removes the special characters from text.

public static string? RemoveSpecialCharacters(this string? value)

Parameters

value string

Text content.

Returns

string

Right(string?, int)

Gets the last characters from string.

public static string? Right(this string? value, int length)

Parameters

value string

String that contains the characters to be extracted.

length int

The number of characters to be extracted.

Returns

string

Exceptions

ArgumentNullException