Class StringExtensions
- Namespace
- SIMDispatcher.Core.Extensions
- Assembly
- SIMDispatcher.Core.dll
public static class StringExtensions
- Inheritance
-
StringExtensions
- Inherited Members
Methods
CapitalizeFirst(string)
Capitalizes the first character of each sentence in the input string.
public static string CapitalizeFirst(this string source)
Parameters
source
stringThe input string to capitalize the first character of each sentence.
Returns
- string
The input string with the first character of each sentence capitalized, or null if the input string is null or empty.
DetectDelimiter(string)
Detects the delimiter used in a CSV string.
public static char DetectDelimiter(this string source)
Parameters
source
string
Returns
- char
The detected delimiter character (',' or ';').
GetAfter(string, string)
Extracts the substring located after the last occurrence of the specified start string within the input string.
public static string? GetAfter(this string source, string start)
Parameters
source
stringThe input string from which to extract the substring.
start
stringThe starting string marking the position after which to extract the substring.
Returns
- string
The substring located after the last occurrence of the start string, or null if the input string is null, empty, or if the start string is not found.
GetBetween(string, string, string)
Extracts the substring located between the specified start and end strings within the input string.
public static string? GetBetween(this string source, string start, string end)
Parameters
source
stringThe input string from which to extract the substring.
start
stringThe starting string marking the beginning of the substring to extract.
end
stringThe ending string marking the end of the substring to extract.
Returns
- string
The substring located between the start and end strings, or null if the input string is null, empty, or if the start or end strings are not found.
IsEmailAddress(string)
Checks if the provided string is a valid email address.
public static bool IsEmailAddress(this string source)
Parameters
source
stringThe input string to check for a valid email address.
Returns
- bool
True if is valid email address. False if not.
SafeUserInput(string?, int, bool)
Sanitizes and validates user input to prevent common security vulnerabilities and ensure consistency.
public static string? SafeUserInput(this string? source, int maxLength = -1, bool removeReturn = true)
Parameters
source
stringThe input string to sanitize.
maxLength
intThe maximum length allowed for the input string (default is -1 for no limit).
removeReturn
boolIndicates whether to remove carriage return and newline characters (default is true).
Returns
- string
The sanitized and validated input string, or null if the input string is null, empty, or contains only whitespace.
TryParseLatitude(string, out double)
Tries to parse the input string as a latitude value, using the specified culture for number formatting.
public static bool TryParseLatitude(this string source, out double latitude)
Parameters
source
stringThe input string to parse as a latitude value.
latitude
doubleWhen this method returns, contains the parsed latitude value if parsing succeeded, or zero if parsing failed.
Returns
- bool
True if the input string was successfully parsed as a latitude value; otherwise, false.
TryParseLongitude(string, out double)
Tries to parse the input string as a longitude value, using the specified culture for number formatting.
public static bool TryParseLongitude(this string source, out double longitude)
Parameters
source
stringThe input string to parse as a longitude value.
longitude
doubleWhen this method returns, contains the parsed longitude value if parsing succeeded, or zero if parsing failed.
Returns
- bool
True if the input string was successfully parsed as a longitude value; otherwise, false.
UppercaseFirst(string)
Converts the first character of the input string to uppercase.
public static string UppercaseFirst(this string source)
Parameters
source
stringThe input string to capitalize the first character.
Returns
- string
The input string with the first character capitalized, or null if the input string is null, empty, or contains only whitespace.