Skip to content

StringHelper class

namespace: Serenity   assemblySerenity.Net.Core

This static class contains some helper functions that operate on String objects.

public static class StringHelper

Public Members

name description
static readonly InvalidFilenameCharsRegex A regex to remove invalid file name characters
static readonly InvalidPathCharsRegex A regex to remove invalid file path characters
static IsEmptyOrNull(…) This function is just an extension method version of string.IsNullOrEmpty and is effectively obsolete. (2 methods)
static IsNullOrEmpty(…) This function is just an extension method version of string.IsNullOrEmpty and is effectively obsolete.
static IsTrimmedEmpty(…) This function is just an extension method version of string.IsNullOrWhitespace and is effectively obsolete.
static IsTrimmedSame(…) Compares two strings ignoring whitespace at the left or right.
static Join(…) Joins two strings conditionally, by putting separator between if both are non empty
static JoinNonEmpty(…) Joins strings conditionally, by putting separator between if both are non empty or null (2 methods)
static QuoteString(…) Quotes a string.
static RemoveDiacritics(…) Removes the diacritic characters from string by replacing them with ASCII versions.
static SafeSubstring(…) A substring function that doesn't raise out of bound errors or null reference exception.
static SanitizeFilename(…) Sanitizes the filename by removing diacritics, ı with i and replacing any invalid filename characters with underscore.
static SanitizeFilePath(…) Sanitizes the path by removing diacritics (ü with u, ı with i etc.) and replacing any invalid file path characters with underscore.
static ThreeDots(…) If the string's length is over a specified limit, trims its right side and adds three points ("...").
static ToDoubleQuoted(…) Converts the string to its double quoted representation.
static ToSingleLine(…) Converts the string to single line by replacing line endings with space.
static ToSingleQuoted(…) Converts the string to its single quoted representation.
static ToStringDefault<T>(…) Formats a nullable struct (2 methods)
static TrimToEmpty(…) Removes whitespace characters in the left or right of the String string, and if resulting string is empty or null, returns empty.
static TrimToNull(…) Removes whitespace characters in the left or right of the String string, and if resulting string is empty or null, returns null.

See Also