C# Класс ToolBelt.StringUtility

Groups a set of useful string manipulation and validation methods.
Показать файл Открыть проект

Открытые методы

Метод Описание
ConvertEmptyToNull ( string value ) : string

Converts an empty string ("") to .

ConvertNullToEmpty ( string value ) : string

Converts to an empty string.

CultureFormat ( this format ) : string

Format a string using the current culture. Use for strings returned to user.

InvariantFormat ( this format ) : string

Format a string using the invariant culture. Use for persisted strings not returned to user.

Join ( string separator, IList value ) : string

Concatenates a specified separator string between each element of a specified list, yielding a single concatenated string.

For example if separator is ", " and the elements of value are "apple", "orange", "grape", and "pear", the method returns "apple, orange, grape, pear".

If separator is , an empty string (string.Empty) is used instead.

ReplaceTags ( this source, string tagPrefix, string tagSuffix, IDictionary tagDictionary, TaggedStringOptions flags = TaggedStringOptions.RemoveUnknownTags ) : string

This method searches for each occurrence of a tagged variable in source and replaces it with the value from the a dictionary subs. Comparisons are done case insensitively.

WordWrap ( this text, int lineLength ) : string[]

Breaks a string on word boundaries, to the given lineLength. Only space characters are considered when breaking up lines. Embedded Environment.NewLine sequences will break a line and are not included in the resulting output. Each line is broken after the first whitespace after the last word on the line, so all space characters are preserved in the resulting output.

Описание методов

ConvertEmptyToNull() публичный статический Метод

Converts an empty string ("") to .
public static ConvertEmptyToNull ( string value ) : string
value string The value to convert.
Результат string

ConvertNullToEmpty() публичный статический Метод

Converts to an empty string.
public static ConvertNullToEmpty ( string value ) : string
value string The value to convert.
Результат string

CultureFormat() публичный статический Метод

Format a string using the current culture. Use for strings returned to user.
public static CultureFormat ( this format ) : string
format this
Результат string

InvariantFormat() публичный статический Метод

Format a string using the invariant culture. Use for persisted strings not returned to user.
public static InvariantFormat ( this format ) : string
format this
Результат string

Join() публичный статический Метод

Concatenates a specified separator string between each element of a specified list, yielding a single concatenated string.

For example if separator is ", " and the elements of value are "apple", "orange", "grape", and "pear", the method returns "apple, orange, grape, pear".

If separator is , an empty string (string.Empty) is used instead.

public static Join ( string separator, IList value ) : string
separator string A .
value IList A string collection.
Результат string

ReplaceTags() публичный статический Метод

This method searches for each occurrence of a tagged variable in source and replaces it with the value from the a dictionary subs. Comparisons are done case insensitively.
public static ReplaceTags ( this source, string tagPrefix, string tagSuffix, IDictionary tagDictionary, TaggedStringOptions flags = TaggedStringOptions.RemoveUnknownTags ) : string
source this String containing tagged entities
tagPrefix string The tag prefix
tagSuffix string The tag suffix
tagDictionary IDictionary
flags TaggedStringOptions for the replace operation
Результат string

WordWrap() публичный статический Метод

Breaks a string on word boundaries, to the given lineLength. Only space characters are considered when breaking up lines. Embedded Environment.NewLine sequences will break a line and are not included in the resulting output. Each line is broken after the first whitespace after the last word on the line, so all space characters are preserved in the resulting output.
public static WordWrap ( this text, int lineLength ) : string[]
text this The text to break up.
lineLength int The maximum length of a line
Результат string[]