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(…) Returns true if String is null or empty (zero length) (2 methods)
static IsNullOrEmpty(…) Returns true if String is null or empty (zero length)
static IsTrimmedEmpty(…) Checks if a string String is null, empty or just contains whitespace characters.
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 i and replacing any invalid file path characters with underscore.
static ThreeDots(…) If the string's length is over a specified limit, trims its right 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