Click or drag to resize

StringExtensions Methods

The StringExtensions type exposes the following members.

Methods
  NameDescription
Public methodStatic memberAnsiQuote
Quote a string for a SQL statement including escaping embedded ticks.
Public methodStatic memberContains
Returns a value indicating whether the specified value occurs in this string. This method is safe to call on searching with a null string and/or seeking a null string.
Public methodStatic memberContainsCI
Null-safe, case-insensitive (using OrdinalIgnoreCase) determination of whether or not this string contains the specified string. Note: If either string is null or empty then false is returned.
Public methodStatic memberCount
Returns the number of instances of a particular character in a string
Public methodStatic memberDistinctChars
Extract a string comprised of the distinct characters in the string provided. For exaple "ABBCADEF".DistinctChars() will return a six character string containing a single A, B, C, D, E, F (e.g. "ABCDEF", or "DCABFE"), in no particular order.
Public methodStatic memberEqualsCI
Null-safe comparison of two strings case-insensitively (using OrdinalIgnoreCase).
Public methodStatic memberFirst(String)
Gets the first character of the string. The returned string always will be zero or one character long, and never null. The original string may be null or empty. If the original string is null or empty, string.Empty will be returned otherwise the first character of the string will be returned.
Public methodStatic memberFirst(String, Int32)
Gets the first n characters of the string. The returned string always will be the specified length or shorter, and never null. The original string may be null or empty. If the original string is null or shorter than requested, the returned string will be returned (or string.Empty if null). If the original string is longer than requested, the returned string will be truncated to the requested length.
Public methodStatic memberFirst(String, Int32, Char)
Gets the first n characters of the string. The returned string always will be exactly the specified length, and never null. The original string may be null or empty. If the original string is null, empty, or shorter than requested, the returned string will be right-padded with the pad charcter. If the original string is longer than requested, the returned string will be truncated to the requested length.
Public methodStatic memberGetValueOrDefault
Retrieves the value of the current string, or, if null/empty, the specified default value.
Public methodStatic memberHasValue
Null-safe test to determine whether the string has a value (is NOT null or empty). See also IsNullOrEmpty(String)
Public methodStatic memberIsGuid
Returns true if the string is a valid guid. If the string is null or empty the return is false.
Public methodStatic memberIsNullOrEmpty
Null-safe test to determine whether the string is null or empty. See also HasValue(String)
Public methodStatic memberIsNumeric
Returns true if the string is numeric
Public methodStatic memberJString(NullableGuid)
Convert a guid to a quoted java string.
Public methodStatic memberJString(String)
Convert a string to a quoted java string including escaping embedded ticks and certain other characters.
Public methodStatic memberReplace
Replace all instances of a specified System.String in this instance, with another specified System.String using the specified comparison type. This allows for case-insensitive replacements.
Public methodStatic memberReplaceCI
Replace all instances of a specified System.String in this instance, with another specified System.String using the OrdingalIgnoreCase comparison type.
Public methodStatic memberReverse
Reverses the characters in the string.
Public methodStatic memberSpanExcluding
Extracts the span of characters from the beginning of the specified string up to, but excluding, the first character that is in the set of characters to exclude. If so such characters are found, the entire string is returned. The behaviour is the sames as the C++ CString::SpanExcluding() method.
Public methodStatic memberSpanIncluding
Extracts the span of characters at the beginning of the specified string that are in the set of specified characters. The behaviour is the sames as the C++ CString::SpanIncluding() method.
Public methodStatic memberSplit(String, StringSplitOptions, Char)
Split a string on the specified single character separator according to the specified options.
Public methodStatic memberSplit(String, StringSplitOptions, String)
Split a string on any of characters in the separator string according to the specified options.
Public methodStatic memberSubstringJS
Implements the javascript string.substring() function which differs from the C# string.Substring() method in that the 2nd argument is the index of the first character to exclude vs. the character count. The rules for handling the two indices are as described in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring.
Public methodStatic memberTagGet
Returns the value of the specified item. If no such item is found an empty string is returned. In the tag string name and value are separated by an equals sign ("=") and name/value pairs are separated by ampersands. Internally each value is UriEncoded to allow for values having ampersands or equals sign. The UriDecoding is performed by this method. Use TagSet(String, String, String) to set a value by name.
Public methodStatic memberTagSet
Returns the string updated to include the specified name/value pair. If there is already an item with the specified name then its value is updated, else a new item is added. In the tag string name and value are separated by an equals sign ("=") and name/value pairs are separated by ampersands. Internally each value is UriEncoded to allow for values having ampersands or equals sign. The UriEncoding is performed by this method. Use TagGet(String, String) to retrieve a value by name.
Public methodStatic memberTruncate
Truncates the string to no more than the specified number of characters. If truncation is requires an ellipsis is always (...) added.
Top
See Also