StringExtensions Class

Defines extension functions related to string manipulation.

Definition

Namespace: Gemstone.StringExtensions
Assembly: Gemstone.Common (in Gemstone.Common.dll) Version: 1.0.128 -- Release Build+d050cfc5563c89a1188cc3c6b2d417530856f490
public static class StringExtensions
Inheritance
Object    StringExtensions

Methods

Base64Decode Decodes a given base-64 encoded string encoded with Base64Encode(String).
Base64Encode Encodes a string into a base-64 string.
CenterText(String, Int32) Centers text within the specified maximum length, biased to the left. Text will be padded to the left and right with spaces. If value is greater than specified maximum length, value returned will be truncated from the right.
CenterText(String, Int32, Char) Centers text within the specified maximum length, biased to the left. Text will be padded to the left and right with specified padding character. If value is greater than specified maximum length, value returned will be truncated from the right.
CharCount Counts the total number of the occurrences of a character in the given string.
ConvertToType(String, Type) Converts this string into the specified type.
ConvertToType(String, Type, CultureInfo, Boolean) Converts this string into the specified type.
ConvertToTypeT(String) Converts this string into the specified type.
ConvertToTypeT(String, CultureInfo) Converts this string into the specified type.
EnsureEnd(String, Char) Ensures a string ends with a specific character.
EnsureEnd(String, String) Ensures a string ends with a specific string.
EnsureEnd(String, Char, Boolean) Ensures a string ends with a specific character.
EnsureStart(String, Char) Ensures a string starts with a specific character.
EnsureStart(String, String) Ensures a string starts with a specific string.
EnsureStart(String, Char, Boolean) Ensures a string starts with a specific character.
GetComparer Gets appropriate StringComparer for the specified StringComparison.
GetSegments Turns source string into an array of string segments - each with a set maximum width - for parsing or displaying.
IndexOfNot(String, Char, Int32) Finds the first index that does not match the given character.
IndexOfNot(String, Char, Int32) Finds the first index that is NOT included in testChars
IndexOfNot(String, FuncChar, Boolean, Int32) Finds the first index that does NOT pass the characterTestFunction delegate function.
IndexOfPrevious(String, Char, Int32) Searches a string from right to left for the next instance of a specified character.
IndexOfPrevious(String, FuncChar, Boolean, Int32) Searches a string from right to left for the next instance of a character passing the specified delegate.
IndexOfPrevious(String, String, Int32, Boolean) Searches a string from right to left for the next instance of a specified string.
IndexOfPreviousNot(String, Char, Int32) Searches a string from right to left for the next instance of a character that is not the specified character.
IndexOfPreviousNot(String, Char, Int32) Searches a string from right to left for the next instance of a character that is not contained in the specified collection of characters.
IndexOfPreviousNot(String, FuncChar, Boolean, Int32) Searches a string from right to left for the next instance of a character that does not pass the given delegate function.
IndexOfRepeatedChar(String) Searches a string for an instance of a repeated character.
IndexOfRepeatedChar(String, Char) Searches a string for a repeated instance of the specified characterToFind.
IndexOfRepeatedChar(String, Int32) Searches a string for an instance of a repeated character from specified startIndex.
IndexOfRepeatedChar(String, Char, Int32) Searches a string for a repeated instance of the specified characterToFind from specified startIndex.
Interpolate(String, IEnumerableKeyValuePairString, Object) Applies string interpolation to the given format string at runtime.
InterpolateT(String, T) Applies string interpolation to the given format string at runtime.
IsAllDigits Tests to see if a string is contains only digits based on Char.IsDigit function.
IsAllLetters(String) Tests to see if a string contains only letters.
IsAllLetters(String, Boolean) Tests to see if a string contains only letters.
IsAllLettersOrDigits(String) Tests to see if a string contains only letters or digits.
IsAllLettersOrDigits(String, Boolean) Tests to see if a string contains only letters or digits.
IsAllLower Tests to see if a string's letters are all lower case.
IsAllNumbers Tests to see if a string contains only numbers based on Char.IsNumber function.
IsAllUpper Tests to see if a string's letters are all upper case.
JoinKeyValuePairs Combines a dictionary of key-value pairs in to a string.
NotEmpty(String) Ensures parameter is not an empty or null string. Returns a single space if test value is empty.
NotEmpty(String, String) Ensures parameter is not an empty or null string.
ParseBoolean Parses a string intended to represent a boolean value.
ParseKeyValuePairs Parses key/value pair expressions from a string. Parameter pairs are delimited by keyValueDelimiter and multiple pairs separated by parameterDelimiter. Supports encapsulated nested expressions.
QuoteUnwrap(String, Char) Unwraps quotes similar to Excel. However, a little more predictable for unusual edge cases.
QuoteUnwrap(String, Char) Unwraps quotes similar to Excel. However, a little more predictable for unusual edge cases.
QuoteWrap Wraps value in the quoteChar.
RegexDecode Decodes the specified Regular Expression character back into a standard Unicode character.
RemoveCharacter Removes all characters matching the given characterToRemove.
RemoveCharacters Removes all characters passing delegate test from a string.
RemoveControlCharacters Removes all control characters from a string.
RemoveCrLfs Removes all carriage returns and line feeds from a string.
RemoveDuplicates Removes duplicate character strings (adjoining replication) in a string.
RemoveDuplicateWhiteSpace(String) Replaces all repeating white space with a single space.
RemoveDuplicateWhiteSpace(String, Char) Replaces all repeating white space with specified spacing character.
RemoveInvalidFileNameCharacters Removes all invalid file name characters (\ / : * ? " < > |) from a string.
RemoveLeadingString(String, Char, Boolean) Removes one or more instances of a specified char from the beginning of a string.
RemoveLeadingString(String, String, Boolean) Removes one or more instances of a specified string from the beginning of a string.
RemoveLeadingZeros Assures that numeric value is a well formed number Adds a leading zero in front of a decimal, if present
RemoveNull Removes the terminator ('\0') from a null terminated string.
RemoveTrailingString(String, Char, Boolean) Removes one or more instances of a character from the end of a string
RemoveTrailingString(String, String, Boolean) Removes one or more instances of a string from the end of a string
RemoveWhiteSpace Removes all white space (as defined by IsWhiteSpace) from a string.
ReplaceCaseInsensitive Performs a case insensitive string replacement.
ReplaceCharacters Replaces all characters passing delegate test with specified replacement character.
ReplaceControlCharacters(String) Replaces all control characters in a string with a single space.
ReplaceControlCharacters(String, Char) Replaces all control characters in a string with specified replacement character.
ReplaceCrLfs Replaces all carriage return and line feed characters (as well as CR/LF sequences) in a string with specified replacement character.
ReplaceInvalidFileNameCharacters Replaces all invalid file name characters (\ / : * ? " < > |) in a string with the specified replacementCharacter.
ReplaceWhiteSpace Replaces all white space characters (as defined by IsWhiteSpace) with specified replacement character.
Reverse Reverses the order of the characters in a string.
StringCount Counts the total number of the occurrences of string within a string
SubstringEnd Returns a string consisting of a specified number of characters from the end of a string "to the left"
SubstringPrevious Returns a string consisting of a specified number of characters to the left (previous chars) from the provided startIndex
ThrowIfNullOrEmpty Throws an ArgumentNullException if argument is null -or- an ArgumentException if argument is Empty.
ToCamelCase Converts first letter of string to lower-case.
ToNonNullNorEmptyStringT Converts value to string; null objects, DBNull objects or empty strings will return specified nonNullNorEmptyValue.
ToNonNullNorWhiteSpaceT Converts value to string; null objects, DBNull objects, empty strings or all white space strings will return specified nonNullNorWhiteSpaceValue.
ToNonNullString(String) Makes sure returned string value is not null; if this string is null, empty string ("") will be returned.
ToNonNullStringT(T) Converts value to string; null objects (or DBNull objects) will return an empty string ("").
ToNonNullStringT(T, String) Converts value to string; null objects (or DBNull objects) will return specified nonNullValue.
ToPascalCase Converts first letter of string to upper-case.
ToSecureString Converts the given string into a SecureString.
ToSpacedLabel Converts the provided string, assumed to be title, pascal or camel case formatted, to a label with spaces before each capital letter, other than the first.
ToStream Converts string into a stream using the specified encoding.
ToStreamAsync Asynchronously converts string into a stream using the specified encoding.
ToTitleCase Converts the provided string into title case (upper case first letter of each word).
ToUnsecureString Converts the given SecureString into a String.
TrimWithEllipsisEnd Places an ellipsis at the end of a string as it is trimmed to length specified.
TrimWithEllipsisMiddle Places an ellipsis in the middle of a string as it is trimmed to length specified.
TruncateLeft Truncates the provided string from the left if it is longer that specified length.
TruncateRight Truncates the provided string from the right if it is longer that specified length.
UriEncode Escapes string using URL encoding.

See Also