Table of Contents

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

stringBuilder StringBuilder

StringBuilder to append to

format string

Format string

args string[]

Format arguments

Contains(StringBuilder, string)

Determines whether the StringBuilder contains the specified string

public static bool Contains(this StringBuilder stringBuilder, string value)

Parameters

stringBuilder StringBuilder

StringBuilder to search in

value string

String 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

stringBuilder StringBuilder

StringBuilder to check

value string

String 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

stringBuilder StringBuilder

StringBuilder to search in

value string

String 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

stringBuilder StringBuilder

StringBuilder to check

value string

String 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

stringBuilder StringBuilder

StringBuilder to extract from

indexFrom int

Starting 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

stringBuilder StringBuilder

StringBuilder to extract from

index int

Starting position

length int

Number 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

stringBuilder StringBuilder

StringBuilder to trim

TrimEnd(StringBuilder)

Removes trailing whitespace from the end of the StringBuilder

public static void TrimEnd(this StringBuilder stringBuilder)

Parameters

stringBuilder StringBuilder

StringBuilder 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

stringBuilder StringBuilder

StringBuilder to process

suffix string

Suffix 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

stringBuilder StringBuilder

StringBuilder 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

stringBuilder StringBuilder

StringBuilder to process

prefix string

Prefix to remove

Returns

StringBuilder

StringBuilder with prefix removed