NanoByte.Common  2.9.0
NanoByte.Common.StringUtils Class Reference

Provides additional or simplified string functions. More...

Static Public Member Functions

static bool EqualsIgnoreCase (string? s1, string? s2)
 Compares strings using case-insensitive comparison. More...
 
static bool EqualsIgnoreCase (char c1, char c2)
 Compares chars using case-insensitive comparison. More...
 
static bool EqualsEmptyNull (string? s1, string? s2)
 Compares strings using case sensitive, invariant culture comparison and considering null and string.Empty equal. More...
 
static bool ContainsIgnoreCase (this string value, string searchFor)
 Determines whether a string contains searchFor using case-insensitive comparison. More...
 
static bool ContainsWhitespace (this string value)
 Determines whether a string contains any whitespace characters. More...
 
static bool StartsWith (this string value, string searchFor, [NotNullWhen(true)] out string? rest)
 Determines whether a string starts with searchFor and, if so, returns the rest that comes after. More...
 
static bool EndsWith (this string value, string searchFor, [NotNullWhen(true)] out string? rest)
 Determines whether a string starts with searchFor and, if so, returns the rest that comes after. More...
 
static bool StartsWithIgnoreCase (this string value, string searchFor)
 Determines whether a string starts with searchFor with case-insensitive comparison. More...
 
static bool EndsWithIgnoreCase (this string value, string searchFor)
 Determines whether a string ends with searchFor with case-insensitive comparison. More...
 
static ? string RemoveCharacters (this string? value, [InstantHandle] IEnumerable< char > characters)
 Removes all occurrences of a specific set of characters from a string. More...
 
static string TrimOverflow (this string value, int maxLength)
 Cuts off strings longer than maxLength and replaces the rest with ellipsis (...). More...
 
static string[] SplitMultilineText (this string value)
 Splits a multiline string to several strings and returns the result as a string array. More...
 
static string Join (string separator, [InstantHandle] IEnumerable< string > parts)
 Combines multiple strings into one, placing a separator between the parts . More...
 
static string GetLeftPartAtFirstOccurrence (this string value, char searchFor)
 Get everything to the left of the first occurrence of a character. More...
 
static string GetRightPartAtFirstOccurrence (this string value, char searchFor)
 Get everything to the right of the first occurrence of a character. More...
 
static string GetLeftPartAtLastOccurrence (this string value, char searchFor)
 Get everything to the left of the last occurrence of a character. More...
 
static string GetRightPartAtLastOccurrence (this string value, char searchFor)
 Get everything to the right of the last occurrence of a character. More...
 
static string GetLeftPartAtFirstOccurrence (this string value, string searchFor)
 Get everything to the left of the first occurrence of a string. More...
 
static string GetRightPartAtFirstOccurrence (this string value, string searchFor)
 Get everything to the right of the first occurrence of a string. More...
 
static string GetLeftPartAtLastOccurrence (this string value, string searchFor)
 Get everything to the left of the last occurrence of a string. More...
 
static string GetRightPartAtLastOccurrence (this string value, string searchFor)
 Get everything to the right of the last occurrence of a string. More...
 
static string FormatBytes (this long value, IFormatProvider? provider=null)
 Formats a byte number in human-readable form (KB, MB, GB). More...
 
static string GeneratePassword (int length)
 Returns a string filled with random human-readable ASCII characters based on a cryptographic random number generator. More...
 

Detailed Description

Provides additional or simplified string functions.

Member Function Documentation

◆ ContainsIgnoreCase()

static bool NanoByte.Common.StringUtils.ContainsIgnoreCase ( this string  value,
string  searchFor 
)
static

Determines whether a string contains searchFor using case-insensitive comparison.

Parameters
valueThe string to search.
searchForThe string to search for in value .

◆ ContainsWhitespace()

static bool NanoByte.Common.StringUtils.ContainsWhitespace ( this string  value)
static

Determines whether a string contains any whitespace characters.

◆ EndsWith()

static bool NanoByte.Common.StringUtils.EndsWith ( this string  value,
string  searchFor,
[NotNullWhen(true)] out string?  rest 
)
inlinestatic

Determines whether a string starts with searchFor and, if so, returns the rest that comes after.

◆ EndsWithIgnoreCase()

static bool NanoByte.Common.StringUtils.EndsWithIgnoreCase ( this string  value,
string  searchFor 
)
static

Determines whether a string ends with searchFor with case-insensitive comparison.

◆ EqualsEmptyNull()

static bool NanoByte.Common.StringUtils.EqualsEmptyNull ( string?  s1,
string?  s2 
)
static

Compares strings using case sensitive, invariant culture comparison and considering null and string.Empty equal.

◆ EqualsIgnoreCase() [1/2]

static bool NanoByte.Common.StringUtils.EqualsIgnoreCase ( char  c1,
char  c2 
)
static

Compares chars using case-insensitive comparison.

◆ EqualsIgnoreCase() [2/2]

static bool NanoByte.Common.StringUtils.EqualsIgnoreCase ( string?  s1,
string?  s2 
)
static

Compares strings using case-insensitive comparison.

◆ FormatBytes()

static string NanoByte.Common.StringUtils.FormatBytes ( this long  value,
IFormatProvider?  provider = null 
)
inlinestatic

Formats a byte number in human-readable form (KB, MB, GB).

Parameters
valueThe value in bytes.
providerProvides culture-specific formatting information.

◆ GeneratePassword()

static string NanoByte.Common.StringUtils.GeneratePassword ( int  length)
inlinestatic

Returns a string filled with random human-readable ASCII characters based on a cryptographic random number generator.

Parameters
lengthThe length of the string to be generated.

◆ GetLeftPartAtFirstOccurrence() [1/2]

static string NanoByte.Common.StringUtils.GetLeftPartAtFirstOccurrence ( this string  value,
char  searchFor 
)
inlinestatic

Get everything to the left of the first occurrence of a character.

◆ GetLeftPartAtFirstOccurrence() [2/2]

static string NanoByte.Common.StringUtils.GetLeftPartAtFirstOccurrence ( this string  value,
string  searchFor 
)
inlinestatic

Get everything to the left of the first occurrence of a string.

◆ GetLeftPartAtLastOccurrence() [1/2]

static string NanoByte.Common.StringUtils.GetLeftPartAtLastOccurrence ( this string  value,
char  searchFor 
)
inlinestatic

Get everything to the left of the last occurrence of a character.

◆ GetLeftPartAtLastOccurrence() [2/2]

static string NanoByte.Common.StringUtils.GetLeftPartAtLastOccurrence ( this string  value,
string  searchFor 
)
inlinestatic

Get everything to the left of the last occurrence of a string.

◆ GetRightPartAtFirstOccurrence() [1/2]

static string NanoByte.Common.StringUtils.GetRightPartAtFirstOccurrence ( this string  value,
char  searchFor 
)
inlinestatic

Get everything to the right of the first occurrence of a character.

◆ GetRightPartAtFirstOccurrence() [2/2]

static string NanoByte.Common.StringUtils.GetRightPartAtFirstOccurrence ( this string  value,
string  searchFor 
)
inlinestatic

Get everything to the right of the first occurrence of a string.

◆ GetRightPartAtLastOccurrence() [1/2]

static string NanoByte.Common.StringUtils.GetRightPartAtLastOccurrence ( this string  value,
char  searchFor 
)
inlinestatic

Get everything to the right of the last occurrence of a character.

◆ GetRightPartAtLastOccurrence() [2/2]

static string NanoByte.Common.StringUtils.GetRightPartAtLastOccurrence ( this string  value,
string  searchFor 
)
inlinestatic

Get everything to the right of the last occurrence of a string.

◆ Join()

static string NanoByte.Common.StringUtils.Join ( string  separator,
[InstantHandle] IEnumerable< string >  parts 
)
static

Combines multiple strings into one, placing a separator between the parts .

Parameters
separatorThe separator characters to place between the parts .
partsThe strings to be combined.

◆ RemoveCharacters()

static ? string NanoByte.Common.StringUtils.RemoveCharacters ( this string?  value,
[InstantHandle] IEnumerable< char >  characters 
)
static

Removes all occurrences of a specific set of characters from a string.

◆ SplitMultilineText()

static string [] NanoByte.Common.StringUtils.SplitMultilineText ( this string  value)
inlinestatic

Splits a multiline string to several strings and returns the result as a string array.

◆ StartsWith()

static bool NanoByte.Common.StringUtils.StartsWith ( this string  value,
string  searchFor,
[NotNullWhen(true)] out string?  rest 
)
inlinestatic

Determines whether a string starts with searchFor and, if so, returns the rest that comes after.

◆ StartsWithIgnoreCase()

static bool NanoByte.Common.StringUtils.StartsWithIgnoreCase ( this string  value,
string  searchFor 
)
static

Determines whether a string starts with searchFor with case-insensitive comparison.

◆ TrimOverflow()

static string NanoByte.Common.StringUtils.TrimOverflow ( this string  value,
int  maxLength 
)
static

Cuts off strings longer than maxLength and replaces the rest with ellipsis (...).


The documentation for this class was generated from the following file: