Class StringBuilderExtensions
- Namespace
- SunamoExtensions
- Assembly
- SunamoExtensions.dll
Extension methods for StringBuilder type
public static class StringBuilderExtensions
- Inheritance
-
StringBuilderExtensions
- Inherited Members
Methods
AppendFormatLine(StringBuilder, string, params string[])
Appends a formatted string followed by a line terminator
public static void AppendFormatLine(this StringBuilder stringBuilder, string format, params string[] args)
Parameters
stringBuilderStringBuilderStringBuilder to append to
formatstringFormat string
argsstring[]Format arguments
Contains(StringBuilder, string)
Determines whether the StringBuilder contains the specified string
public static bool Contains(this StringBuilder stringBuilder, string value)
Parameters
stringBuilderStringBuilderStringBuilder to search in
valuestringString to search for
Returns
- bool
True if the string is found
EndsWith(StringBuilder, string)
Determines whether the end of the StringBuilder matches the specified string
public static bool EndsWith(this StringBuilder stringBuilder, string value)
Parameters
stringBuilderStringBuilderStringBuilder to check
valuestringString to compare
Returns
- bool
True if StringBuilder ends with the specified value
IndexOf(StringBuilder, string)
Returns the index of the first occurrence of the specified string in the StringBuilder
public static int IndexOf(this StringBuilder stringBuilder, string value)
Parameters
stringBuilderStringBuilderStringBuilder to search in
valuestringString to search for
Returns
- int
Index of the first occurrence, or -1 if not found
Exceptions
- ArgumentNullException
Thrown when stringBuilder or value is null
StartWith(StringBuilder, string)
Determines whether the beginning of the StringBuilder matches the specified string
public static bool StartWith(this StringBuilder stringBuilder, string value)
Parameters
stringBuilderStringBuilderStringBuilder to check
valuestringString to compare
Returns
- bool
True if StringBuilder starts with the specified value
Substring(StringBuilder, int)
Retrieves a substring from this StringBuilder starting at the specified position
public static StringBuilder Substring(this StringBuilder stringBuilder, int indexFrom = 1)
Parameters
stringBuilderStringBuilderStringBuilder to extract from
indexFromintStarting position (default: 1)
Returns
- StringBuilder
Substring as StringBuilder
Substring(StringBuilder, int, int)
Retrieves a substring from this StringBuilder with specified start position and length
public static StringBuilder Substring(this StringBuilder stringBuilder, int index, int length)
Parameters
stringBuilderStringBuilderStringBuilder to extract from
indexintStarting position
lengthintNumber of characters to extract
Returns
- StringBuilder
Substring as StringBuilder
Exceptions
- ArgumentOutOfRangeException
Thrown when index or length is out of range
Trim(StringBuilder)
Removes leading and trailing whitespace from the StringBuilder
public static void Trim(this StringBuilder stringBuilder)
Parameters
stringBuilderStringBuilderStringBuilder to trim
TrimEnd(StringBuilder)
Removes trailing whitespace from the end of the StringBuilder
public static void TrimEnd(this StringBuilder stringBuilder)
Parameters
stringBuilderStringBuilderStringBuilder to trim
TrimEnd(StringBuilder, string)
Removes all occurrences of the specified suffix from the end of the StringBuilder
public static StringBuilder TrimEnd(this StringBuilder stringBuilder, string suffix)
Parameters
stringBuilderStringBuilderStringBuilder to process
suffixstringSuffix to remove
Returns
- StringBuilder
StringBuilder with suffix removed
TrimStart(StringBuilder)
Removes leading whitespace from the start of the StringBuilder
public static void TrimStart(this StringBuilder stringBuilder)
Parameters
stringBuilderStringBuilderStringBuilder to trim
TrimStart(StringBuilder, string)
Removes all occurrences of the specified prefix from the start of the StringBuilder
public static StringBuilder TrimStart(this StringBuilder stringBuilder, string prefix)
Parameters
stringBuilderStringBuilderStringBuilder to process
prefixstringPrefix to remove
Returns
- StringBuilder
StringBuilder with prefix removed