Class StringExtensions
public static class StringExtensions
- Inheritance
-
StringExtensions
- Inherited Members
Methods
CleanSplit(string)
public static string[] CleanSplit(this string text)
Parameters
textstring
Returns
- string[]
CleanSplit(string, char[])
public static string[] CleanSplit(this string text, char[] delimiters)
Parameters
Returns
- string[]
CleanTrim(string)
public static string CleanTrim(this string text)
Parameters
textstring
Returns
Contains(string, string, StringComparison)
public static bool Contains(this string str, string substr, StringComparison comparisonType)
Parameters
strstringsubstrstringcomparisonTypeStringComparison
Returns
EmptyIfNull(string)
public static string EmptyIfNull(this string value)
Parameters
valuestring
Returns
Format(string, object)
public static string Format(this string format, object arg0)
Parameters
Returns
Format(string, object, object)
public static string Format(this string format, object arg0, object arg1)
Parameters
Returns
Format(string, object, object, object)
public static string Format(this string format, object arg0, object arg1, object arg2)
Parameters
Returns
Format(string, params object[])
public static string Format(this string format, params object[] args)
Parameters
Returns
HasNoValue(string)
public static bool HasNoValue(this string s)
Parameters
sstring
Returns
HasValue(string)
public static bool HasValue(this string s)
Parameters
sstring
Returns
IfNullOrEmpty(string, Func<string>)
public static string IfNullOrEmpty(this string value, Func<string> nullValueFactory)
Parameters
Returns
IfNullOrEmpty(string, string)
public static string IfNullOrEmpty(this string value, string nullValue)
Parameters
Returns
IsEmpty(string)
public static bool IsEmpty(this string s)
Parameters
sstring
Returns
IsNotEmpty(string)
public static bool IsNotEmpty(this string s)
Parameters
sstring
Returns
Matches(string, string)
Returns true if a string matches another string.
public static bool Matches(this string value, string other)
Parameters
Returns
Remarks
This is not case-sensitive, two null values match, and any two whitespace values match.
MatchesAny(string, IEnumerable<string>)
Returns true if a string has one or more matches in an array of other strings.
public static bool MatchesAny(this string value, IEnumerable<string> others)
Parameters
valuestringothersIEnumerable<string>
Returns
MatchesNone(string, IEnumerable<string>)
Returns true if a string has zero matches in an array of other strings.
public static bool MatchesNone(this string value, IEnumerable<string> others)
Parameters
valuestringothersIEnumerable<string>
Returns
MaxLength(string, int, bool)
public static string MaxLength(this string value, int maxLength, bool addEllipsis = false)
Parameters
Returns
NullIf(string, string, bool)
public static string NullIf(this string value, string nullValue, bool ignoreCase = false)
Parameters
Returns
NullIfEmpty(string)
public static string NullIfEmpty(this string value)
Parameters
valuestring
Returns
NullIfWhiteSpace(string)
public static string NullIfWhiteSpace(this string value)
Parameters
valuestring
Returns
Parse(string)
Converts a string value into a non-null collection.
public static IEnumerable<string> Parse(this string csv)
Parameters
csvstring
Returns
Remarks
Commas and newlines are assumed to be the delimiters. Empty items are removed from the collection. Leading and trailing whitespace characters are removed from each item in the collection.
StartsWithAny(string, IEnumerable<string>)
Returns true if a string starts with any item in an array of strings.
public static bool StartsWithAny(this string value, IEnumerable<string> others)
Parameters
valuestringothersIEnumerable<string>
Returns
ToEnumNullable<T>(string, bool)
public static T? ToEnumNullable<T>(this string value, bool ignoreCase = true) where T : struct, Enum
Parameters
Returns
- T?
Type Parameters
T
ToEnum<T>(string, bool)
public static T ToEnum<T>(this string value, bool ignoreCase = true) where T : struct, Enum
Parameters
Returns
- T
Type Parameters
T
ToEnum<T>(string, Func<string, T>, bool)
public static T ToEnum<T>(this string value, Func<string, T> defaultValueFactory, bool ignoreCase = true) where T : struct, Enum
Parameters
Returns
- T
Type Parameters
T
ToEnum<T>(string, T, bool)
public static T ToEnum<T>(this string value, T defaultValue, bool ignoreCase = true) where T : struct, Enum
Parameters
Returns
- T
Type Parameters
T
ToGuid(string)
public static Guid ToGuid(this string value)
Parameters
valuestring
Returns
ToGuid(string, Guid)
public static Guid ToGuid(this string value, Guid @default)
Parameters
Returns
ToGuidNullable(string)
public static Guid? ToGuidNullable(this string value)
Parameters
valuestring
Returns
- Guid?
ToKebabCase(string, bool)
Converts a string value from PascalCase to kebab-case.
public static string ToKebabCase(this string input, bool allowForwardSlash = false)
Parameters
Returns
Examples
ToKebabCase("ThisIsAnExample") => "this-is-an-example"
ToTitleCase(string)
Converts a string value from PascalCase to Title Case.
public static string ToTitleCase(this string input)
Parameters
inputstring
Returns
Examples
ToTitleCase("ThisIsAnExample") => "This Is An Example"