Class StringUtility
This utility class is designed to make System.String operations easier to work with.
Inheritance
Namespace: Cuemon
Assembly: Cuemon.Core.dll
Syntax
public static class StringUtility
Fields
| Improve this DocAlphanumericCharactersCaseSensitive
A case sensitive representation of an alphanumeric character set consisting of the numbers 0 to 9 and the letters Aa to Zz.
Declaration
public const string AlphanumericCharactersCaseSensitive = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789"
Field Value
Type | Description |
---|---|
System.String |
AlphanumericCharactersSingleCase
A single case representation of an alphanumeric character set consisting of the numbers 0 to 9 and the letters A to Z.
Declaration
public const string AlphanumericCharactersSingleCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
Field Value
Type | Description |
---|---|
System.String |
CarriageReturn
Carriage-return character.
Declaration
public const string CarriageReturn = "\r"
Field Value
Type | Description |
---|---|
System.String |
EnglishAlphabetCharactersMajuscule
An uppercase representation of the English alphabet character set consisting of the letters A to Z.
Declaration
public static readonly string EnglishAlphabetCharactersMajuscule
Field Value
Type | Description |
---|---|
System.String |
EnglishAlphabetCharactersMinuscule
A lowercase representation of the English alphabet character set consisting of the letters a to z.
Declaration
public static readonly string EnglishAlphabetCharactersMinuscule
Field Value
Type | Description |
---|---|
System.String |
HexadecimalCharacters
A representation of a hexadecimal character set consisting of the numbers 0 to 9 and the letters A to F.
Declaration
public static readonly string HexadecimalCharacters
Field Value
Type | Description |
---|---|
System.String |
Linefeed
Linefeed character.
Declaration
public const string Linefeed = "\n"
Field Value
Type | Description |
---|---|
System.String |
NetworkPathReference
A network-path reference, eg. two forward slashes (//).
Declaration
public const string NetworkPathReference = "//"
Field Value
Type | Description |
---|---|
System.String |
NewLine
Carriage-return/linefeed character combination.
Declaration
public const string NewLine = "\r\n"
Field Value
Type | Description |
---|---|
System.String |
NumericCharacters
A representation of a numeric character set consisting of the numbers 0 to 9.
Declaration
public const string NumericCharacters = "0123456789"
Field Value
Type | Description |
---|---|
System.String |
PunctuationMarks
A representation of the most common punctuation marks that conforms to the ASCII printable characters.
Declaration
public static readonly string PunctuationMarks
Field Value
Type | Description |
---|---|
System.String |
Tab
Tab character.
Declaration
public const string Tab = "\t"
Field Value
Type | Description |
---|---|
System.String |
WhiteSpaceCharacters
A representation of the most common whitespace characters.
Declaration
public static readonly string WhiteSpaceCharacters
Field Value
Type | Description |
---|---|
System.String |
Methods
| Improve this DocChunk(String)
Returns a sequence that is chunked into string-slices having a length of 1024 that is equivalent to value
.
Declaration
public static IEnumerable<string> Chunk(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | A System.String to chunk into a sequence of smaller string-slices for partitioned storage or similar. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> | A sequence that is chunked into string-slices having a length of 1024 that is equivalent to |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
Chunk(String, Int32)
Returns a sequence that is chunked into string-slices of the specified length
that is equivalent to value
. Default is 1024.
Declaration
public static IEnumerable<string> Chunk(string value, int length)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | A System.String to chunk into a sequence of smaller string-slices for partitioned storage or similar. |
System.Int32 | length | The desired length of each string-slice in the sequence. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> | A sequence that is chunked into string-slices of the specified |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentOutOfRangeException |
|
Contains(String, Char)
Returns a value indicating whether the specified value
occurs within the source
.
Declaration
public static bool Contains(string source, char value)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The System.String to seek. |
System.Char | value | The System.Char to search within |
Returns
Type | Description |
---|---|
System.Boolean |
|
Remarks
This method performs an ordinal (case-insensitive and culture-insensitive) comparison. The search begins at the first character position of this string and continues through the last character position.
Contains(String, Char, StringComparison)
Returns a value indicating whether the specified value
occurs within the source
.
Declaration
public static bool Contains(string source, char value, StringComparison comparison)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The System.String to seek. |
System.Char | value | The System.Char to search within |
System.StringComparison | comparison | One of the enumeration values that specifies the rules to use in the comparison. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Contains(String, Char[])
Returns a value indicating whether any of the specified values
occurs within the source
.
Declaration
public static bool Contains(string source, params char[] values)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The System.String to seek. |
System.Char[] | values | The System.Char sequence to search within |
Returns
Type | Description |
---|---|
System.Boolean |
|
Remarks
This method performs an ordinal (case-sensitive and culture-insensitive) comparison. The search begins at the first character position of this string and continues through the last character position.
Contains(String, String)
Returns a value indicating whether the specified value
occurs within the source
.
Declaration
public static bool Contains(string source, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The System.String to seek. |
System.String | value | The System.String to search within |
Returns
Type | Description |
---|---|
System.Boolean |
|
Remarks
This method performs an ordinal (case-insensitive and culture-insensitive) comparison. The search begins at the first character position of this string and continues through the last character position.
Contains(String, String, StringComparison)
Returns a value indicating whether the specified value
occurs within the source
.
Declaration
public static bool Contains(string source, string value, StringComparison comparison)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The System.String to seek. |
System.String | value | The System.String to search within |
System.StringComparison | comparison | One of the enumeration values that specifies the rules to use in the comparison. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Contains(String, String[])
Returns a value indicating whether the specified values
occurs within the source
.
Declaration
public static bool Contains(string source, params string[] values)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The System.String to seek. |
System.String[] | values | The System.String sequence to search within |
Returns
Type | Description |
---|---|
System.Boolean |
|
Remarks
This method performs an ordinal (case-insensitive and culture-insensitive) comparison. The search begins at the first character position of this string and continues through the last character position.
Contains(String, StringComparison, Char[])
Returns a value indicating whether any of the specified values
occurs within the source
.
Declaration
public static bool Contains(string source, StringComparison comparison, params char[] values)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The System.String to seek. |
System.StringComparison | comparison | One of the enumeration values that specifies the rules to use in the comparison. |
System.Char[] | values | The System.Char sequence to search within |
Returns
Type | Description |
---|---|
System.Boolean |
|
Contains(String, StringComparison, String[])
Returns a value indicating whether any of the specified values
occurs within the source
.
Declaration
public static bool Contains(string source, StringComparison comparison, params string[] values)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The System.String to seek. |
System.StringComparison | comparison | One of the enumeration values that specifies the rules to use in the comparison. |
System.String[] | values | The System.String sequence to search within |
Returns
Type | Description |
---|---|
System.Boolean |
|
Count(String, Char)
Counts the occurrences of character
in the specified source
.
Declaration
public static int Count(string source, char character)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The source to count occurrences of |
System.Char | character | The System.Char value to count in |
Returns
Type | Description |
---|---|
System.Int32 | The number of times the |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
CreateFixedString(Char, Int32)
Generates a string from the specified Unicode character repeated until the specified length.
Declaration
public static string CreateFixedString(char character, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Char | character | A Unicode character. |
System.Int32 | length | The number of times |
Returns
Type | Description |
---|---|
System.String | A System.String filled with the specified |
CreateRandomString(Int32)
Generates a random string with the specified length using values of AlphanumericCharactersCaseSensitive.
Declaration
public static string CreateRandomString(int length)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | length | The length of the random string to generate. |
Returns
Type | Description |
---|---|
System.String | A random string from the values of AlphanumericCharactersCaseSensitive. |
CreateRandomString(Int32, String[])
Generates a random string with the specified length from the provided values.
Declaration
public static string CreateRandomString(int length, params string[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | length | The length of the random string to generate. |
System.String[] | values | The values to use in the randomization process. |
Returns
Type | Description |
---|---|
System.String | A random string from the values provided. |
Equals(String, String[])
Returns a value indicating the specified source
equals one of the specified values
.
Declaration
public static bool Equals(string source, params string[] values)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The System.String to seek. |
System.String[] | values | The System.String sequence to search within |
Returns
Type | Description |
---|---|
System.Boolean |
|
Remarks
This method performs an ordinal (case-sensitive and culture-insensitive) comparison. The search begins at the first character position of this string and continues through the last character position.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
Equals(String, StringComparison, String[])
Returns a value indicating the specified source
equals one of the specified values
.
Declaration
public static bool Equals(string source, StringComparison comparison, params string[] values)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The System.String to seek. |
System.StringComparison | comparison | One of the enumeration values that specifies the rules to use in the comparison. |
System.String[] | values | The System.String sequence to search within |
Returns
Type | Description |
---|---|
System.Boolean |
|
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
Escape(String)
Escapes the given System.String the same way as the well known JavaScrip escape() function.
Declaration
public static string Escape(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The System.String to escape. |
Returns
Type | Description |
---|---|
System.String | The input |
GetHashCode(String)
Computes a suitable hash code from the specified System.String value
.
Declaration
public static int GetHashCode(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | A System.String value. |
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer that is the hash code of |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
HasConsecutiveCharacters(String, Char, Int32)
Determines whether the specified value
contains a succession character
of length
.
Declaration
public static bool HasConsecutiveCharacters(string value, char character, int length = 2)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to test for consecutive characters. |
System.Char | character | The characters to locate with the specified |
System.Int32 | length | The number of characters in succession. |
Returns
Type | Description |
---|---|
System.Boolean |
|
HasConsecutiveCharacters(String, IEnumerable<Char>, Int32)
Determines whether the specified value
contains at least one of the succession characters
of length
.
Declaration
public static bool HasConsecutiveCharacters(string value, IEnumerable<char> characters, int length = 2)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to test for consecutive characters. |
System.Collections.Generic.IEnumerable<System.Char> | characters | The character to locate with the specified |
System.Int32 | length | The number of characters in succession. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsBase64(String)
Determines whether the specified value
matches a Base64 structure.
Declaration
public static bool IsBase64(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to test for a Base64 structure. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Remarks
This method will skip common Base64 structures typically used as checksums. This includes 32, 128, 160, 256, 384 and 512 bit checksums.
IsBase64(String, Func<String, Boolean>)
Determines whether the specified value
matches a Base64 structure.
Declaration
public static bool IsBase64(string value, Func<string, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to test for a Base64 structure. |
System.Func<System.String, System.Boolean> | predicate | A function delegate that provides custom rules for bypassing the Base64 structure check. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsCountableSequence(String)
Determines whether the specified value
is a sequence of countable characters (hence, characters being either incremented or decremented with the same cardinality through out the sequence).
Declaration
public static bool IsCountableSequence(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to test for a sequence of countable characters. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsNullOrEmpty(IEnumerable<String>)
Determines whether a string sequence has at least one value that equals to null or empty.
Declaration
public static bool IsNullOrEmpty(IEnumerable<string> values)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | values | A string sequence in which to test for the presence of null or empty. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsNullOrEmpty(String[])
Determines whether one or more string values equals to null or empty.
Declaration
public static bool IsNullOrEmpty(params string[] values)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | values | One or more string values to test for the presence of null or empty. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsSequenceOf<T>(IEnumerable<String>)
Determines whether the elements of the specified source
is equivalent to the specified T
.
Declaration
public static bool IsSequenceOf<T>(IEnumerable<string> source)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | source | A sequence in which to evaluate if a string value is equivalent to the specified |
Returns
Type | Description |
---|---|
System.Boolean |
|
Type Parameters
Name | Description |
---|---|
T | The type of the expected values contained within the sequence of |
IsSequenceOf<T>(IEnumerable<String>, Func<String, CultureInfo, Boolean>)
Determines whether the elements of the specified source
is equivalent to the specified T
.
Declaration
public static bool IsSequenceOf<T>(IEnumerable<string> source, Func<string, CultureInfo, bool> parser)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | source | A sequence in which to evaluate if a string value is equivalent to the specified |
System.Func<System.String, System.Globalization.CultureInfo, System.Boolean> | parser | The function delegate that evaluates if the elements of |
Returns
Type | Description |
---|---|
System.Boolean |
|
Type Parameters
Name | Description |
---|---|
T | The type of the expected values contained within the sequence of |
IsSequenceOf<T>(IEnumerable<String>, CultureInfo)
Determines whether the elements of the specified source
is equivalent to the specified T
.
Declaration
public static bool IsSequenceOf<T>(IEnumerable<string> source, CultureInfo culture)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | source | A sequence in which to evaluate if a string value is equivalent to the specified |
System.Globalization.CultureInfo | culture | The culture-specific formatting information to apply on the elements within |
Returns
Type | Description |
---|---|
System.Boolean |
|
Type Parameters
Name | Description |
---|---|
T | The type of the expected values contained within the sequence of |
IsSequenceOf<T>(IEnumerable<String>, CultureInfo, ITypeDescriptorContext)
Determines whether the elements of the specified source
is equivalent to the specified T
.
Declaration
public static bool IsSequenceOf<T>(IEnumerable<string> source, CultureInfo culture, ITypeDescriptorContext context)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | source | A sequence in which to evaluate if a string value is equivalent to the specified |
System.Globalization.CultureInfo | culture | The culture-specific formatting information to apply on the elements within |
System.ComponentModel.ITypeDescriptorContext | context | The type-specific formatting information to apply on the elements within |
Returns
Type | Description |
---|---|
System.Boolean |
|
Type Parameters
Name | Description |
---|---|
T | The type of the expected values contained within the sequence of |
IsSequenceOf<T>(IEnumerable<String>, CultureInfo, Func<String, CultureInfo, Boolean>)
Determines whether the elements of the specified source
is equivalent to the specified T
.
Declaration
public static bool IsSequenceOf<T>(IEnumerable<string> source, CultureInfo culture, Func<string, CultureInfo, bool> parser)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | source | A sequence in which to evaluate if a string value is equivalent to the specified |
System.Globalization.CultureInfo | culture | The culture-specific formatting information to apply on the elements within |
System.Func<System.String, System.Globalization.CultureInfo, System.Boolean> | parser | The function delegate that evaluates if the elements of |
Returns
Type | Description |
---|---|
System.Boolean |
|
Type Parameters
Name | Description |
---|---|
T | The type of the expected values contained within the sequence of |
ParseDistinctDifference(String, String, out String)
Parses whether the two specified values has a distinct difference from each other.
Declaration
public static bool ParseDistinctDifference(string definite, string arbitrary, out string difference)
Parameters
Type | Name | Description |
---|---|---|
System.String | definite | The value that specifies valid characters. |
System.String | arbitrary | The value to distinctively compare with |
System.String | difference | The distinct difference between |
Returns
Type | Description |
---|---|
System.Boolean |
|
ParseFormat(String, Int32, out Int32)
Parses the given string for any format arguments (eg. Text{0}-{1}.).
Declaration
public static bool ParseFormat(string format, int maxArguments, out int foundArguments)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | The desired string format to parse. |
System.Int32 | maxArguments | The maximum allowed arguments in the string format. |
System.Int32 | foundArguments | The number of arguments found in the string format. |
Returns
Type | Description |
---|---|
System.Boolean |
|
ParseFormat(String, out Int32)
Parses the given string for any format arguments (eg. Text{0}-{1}.).
Declaration
public static bool ParseFormat(string format, out int foundArguments)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | The desired string format to parse. |
System.Int32 | foundArguments | The number of arguments found in the string format. |
Returns
Type | Description |
---|---|
System.Boolean |
|
RemoveAll(String, Char[])
Returns a new string in which all the specified filter
values has been deleted from the specified source
.
Declaration
public static string RemoveAll(string source, params char[] filter)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The source to delete occurrences found in |
System.Char[] | filter | The filter containing the characters and/or words to delete. |
Returns
Type | Description |
---|---|
System.String | A new string that is equivalent to |
RemoveAll(String, String[])
Returns a new string in which all the specified filter
values has been deleted from the specified source
.
Declaration
public static string RemoveAll(string source, params string[] filter)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The source to delete occurrences found in |
System.String[] | filter | The filter containing the characters and/or words to delete. |
Returns
Type | Description |
---|---|
System.String | A new string that is equivalent to |
Remarks
This method performs an ordinal (case-sensitive and culture-insensitive) comparison. The search begins at the first character position of this string and continues through the last character position.
RemoveAll(String, StringComparison, String[])
Returns a new string in which all the specified filter
values has been deleted from the specified source
.
Declaration
public static string RemoveAll(string source, StringComparison comparison, params string[] filter)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The source to delete occurrences found in |
System.StringComparison | comparison | One of the enumeration values that specifies the rules to use in the comparison. |
System.String[] | filter | The filter containing the characters and/or words to delete. |
Returns
Type | Description |
---|---|
System.String | A new string that is equivalent to |
RemoveAll(String[], String[])
Returns a new string array in which all the specified filter
values has been deleted from the specified source
array.
Declaration
public static string[] RemoveAll(string[] source, params string[] filter)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | source | The source array to delete occurrences found in |
System.String[] | filter | The filter containing the characters and/or words to delete. |
Returns
Type | Description |
---|---|
System.String[] | A new string array that is equivalent to |
Remarks
This method performs an ordinal (case-sensitive and culture-insensitive) comparison. The search begins at the first character position of this string and continues through the last character position.
RemoveAll(String[], StringComparison, String[])
Returns a new string array in which all the specified filter
values has been deleted from the specified source
array.
Declaration
public static string[] RemoveAll(string[] source, StringComparison comparison, params string[] filter)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | source | The source array to delete occurrences found in |
System.StringComparison | comparison | One of the enumeration values that specifies the rules to use in the comparison. |
System.String[] | filter | The filter containing the characters and/or words to delete. |
Returns
Type | Description |
---|---|
System.String[] | A new string array that is equivalent to |
Replace(String, IEnumerable<StringReplacePair>, StringComparison)
Declaration
public static string Replace(string value, IEnumerable<StringReplacePair> replacePairs, StringComparison comparison)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The System.String value to perform the replacement on. |
System.Collections.Generic.IEnumerable<StringReplacePair> | replacePairs | A sequence of StringReplacePair values. |
System.StringComparison | comparison | One of the enumeration values that specifies the rules to use in the comparison. |
Returns
Type | Description |
---|---|
System.String | A System.String equivalent to |
Replace(String, String, String)
Replaces all occurrences of oldValue
in value
, with newValue
.
Declaration
public static string Replace(string value, string oldValue, string newValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The System.String value to perform the replacement on. |
System.String | oldValue | The System.String value to be replaced. |
System.String | newValue | The System.String value to replace all occurrences of |
Returns
Type | Description |
---|---|
System.String | A System.String equivalent to |
Remarks
This method performs an System.StringComparison.OrdinalIgnoreCase search to find oldValue
.
Replace(String, String, String, StringComparison)
Replaces all occurrences of oldValue
in value
, with newValue
.
Declaration
public static string Replace(string value, string oldValue, string newValue, StringComparison comparison)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The System.String value to perform the replacement on. |
System.String | oldValue | The System.String value to be replaced. |
System.String | newValue | The System.String value to replace all occurrences of |
System.StringComparison | comparison | One of the enumeration values that specifies the rules to use in the comparison. |
Returns
Type | Description |
---|---|
System.String | A System.String equivalent to |
Shuffle(IEnumerable<String>)
Shuffles the specified values
like a deck of cards.
Declaration
public static string Shuffle(IEnumerable<string> values)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | values | The values to be shuffled in the randomization process. |
Returns
Type | Description |
---|---|
System.String | A random string from the shuffled |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentOutOfRangeException |
|
Shuffle(String[])
Shuffles the specified values
like a deck of cards.
Declaration
public static string Shuffle(params string[] values)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | values | The values to be shuffled in the randomization process. |
Returns
Type | Description |
---|---|
System.String | A random string from the shuffled |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentOutOfRangeException |
|
Split(String)
Returns a string array that contains the substrings of value
that are delimited by a comma (",").
Declaration
public static string[] Split(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value containing substrings and delimiters. |
Returns
Type | Description |
---|---|
System.String[] | An array whose elements contain the substrings of |
Remarks
The following table shows the default values for the overloads of this method.
Parameter | Default Value |
---|---|
delimiter | , |
textQualifier | " |
provider | System.Globalization.CultureInfo.InvariantCulture |
Split(String, String)
Returns a string array that contains the substrings of value
that are delimited by delimiter
.
Declaration
public static string[] Split(string value, string delimiter)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value containing substrings and delimiters. |
System.String | delimiter | The delimiter specification. |
Returns
Type | Description |
---|---|
System.String[] | An array whose elements contain the substrings of |
Split(String, String, String)
Returns a string array that contains the substrings of value
that are delimited by delimiter
. A parameter specifies the textQualifier
that surrounds a field.
Declaration
public static string[] Split(string value, string delimiter, string textQualifier)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value containing substrings and delimiters. |
System.String | delimiter | The delimiter specification. |
System.String | textQualifier | The text qualifier specification that surrounds a field. |
Returns
Type | Description |
---|---|
System.String[] | An array whose elements contain the substrings of |
Split(String, String, String, IFormatProvider)
Returns a string array that contains the substrings of value
that are delimited by delimiter
. A parameter specifies the textQualifier
that surrounds a field.
Declaration
public static string[] Split(string value, string delimiter, string textQualifier, IFormatProvider provider)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value containing substrings and delimiters. |
System.String | delimiter | The delimiter specification. |
System.String | textQualifier | The text qualifier specification that surrounds a field. |
System.IFormatProvider | provider | An System.IFormatProvider that supplies culture-specific formatting information. |
Returns
Type | Description |
---|---|
System.String[] | An array whose elements contain the substrings of |
Remarks
This method was inspired by an article on StackOverflow @ http://stackoverflow.com/questions/2807536/split-string-in-c-sharp.
StartsWith(String, IEnumerable<String>)
Determines whether the beginning of an instance of System.String matches at least one string in the specified sequence of strings.
Declaration
public static bool StartsWith(string value, IEnumerable<string> startWithValues)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The System.String to compare. |
System.Collections.Generic.IEnumerable<System.String> | startWithValues | A sequence of System.String values to match against. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Remarks
This match is performed by using a default value of System.StringComparison.OrdinalIgnoreCase.
StartsWith(String, String[])
Determines whether the beginning of an instance of System.String matches at least one string in the specified sequence of strings.
Declaration
public static bool StartsWith(string value, params string[] startWithValues)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The System.String to compare. |
System.String[] | startWithValues | A sequence of System.String values to match against. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Remarks
This match is performed by using a default value of System.StringComparison.OrdinalIgnoreCase.
StartsWith(String, StringComparison, IEnumerable<String>)
Determines whether the beginning of an instance of System.String matches at least one string in the specified sequence of strings.
Declaration
public static bool StartsWith(string value, StringComparison comparison, IEnumerable<string> startWithValues)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The System.String to compare. |
System.StringComparison | comparison | One of the enumeration values that specifies the rules to use in the comparison. |
System.Collections.Generic.IEnumerable<System.String> | startWithValues | A sequence of System.String values to match against. |
Returns
Type | Description |
---|---|
System.Boolean |
|
StartsWith(String, StringComparison, String[])
Determines whether the beginning of an instance of System.String matches at least one string in the specified sequence of strings.
Declaration
public static bool StartsWith(string value, StringComparison comparison, params string[] startWithValues)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The System.String to compare. |
System.StringComparison | comparison | One of the enumeration values that specifies the rules to use in the comparison. |
System.String[] | startWithValues | A sequence of System.String values to match against. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Remarks
This match is performed by using a default value of System.StringComparison.OrdinalIgnoreCase.
TrimAll(String)
Removes all occurrences of white-space characters from the specified value
.
Declaration
public static string TrimAll(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | A System.String value. |
Returns
Type | Description |
---|---|
System.String | The string that remains after all occurrences of white-space characters are removed from the specified |
TrimAll(String, Char[])
Removes all occurrences of a set of characters specified in trimChars
from the specified value
.
Declaration
public static string TrimAll(string value, params char[] trimChars)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | A System.String value. |
System.Char[] | trimChars | An array of Unicode characters to remove. |
Returns
Type | Description |
---|---|
System.String | The string that remains after all occurrences of the characters in the |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
Unescape(String)
Unescapes the given System.String the same way as the well known Javascript unescape() function.
Declaration
public static string Unescape(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The System.String to unescape. |
Returns
Type | Description |
---|---|
System.String | The input |