Class StringEx
Provides static extension methods for the string type.
public static class StringEx
- Inheritance
-
StringEx
- Inherited Members
Methods
IsEmpty(string)
Determines whether the specified string is null or an empty string.
public static bool IsEmpty(this string source)
Parameters
sourcestringThe string to evaluate.
Returns
- bool
trueifsourceisnullor an empty string; otherwise,false.
IsEmptyOrWhiteSpace(string)
Determines whether the specified string is null, empty, or consists only of white-space characters.
public static bool IsEmptyOrWhiteSpace(this string source)
Parameters
sourcestringThe string to evaluate.
Returns
- bool
true if the string is null, empty, or contains only white space; otherwise, false.
SubstringAfter(string, string)
Returns the portion of the source string that follows the first occurrence of the specified value, using ordinal (case-sensitive, culture-insensitive) comparison. If the source or value is null or empty, or the value is not found within the source, the original source is returned unchanged.
public static string SubstringAfter(this string source, string value)
Parameters
sourcestringThe string to search within.
valuestringThe delimiter whose first occurrence marks the start of the returned substring.
Returns
- string
The substring after the first occurrence of
value; otherwise, the originalsource.
SubstringBefore(string, string)
Returns the portion of source that precedes the first occurrence of value, using ordinal comparison.
If either source or value is null or empty, or if value is not found within source, the original source is returned unchanged.
public static string SubstringBefore(this string source, string value)
Parameters
sourcestringThe string to extract the substring from.
valuestringThe delimiter whose first occurrence marks the end of the returned substring.
Returns
- string
The substring of
sourcebefore the first occurrence ofvalue, or the originalsourcewhen no match is found or when either input is null or empty.