Class StringExtensions
Represents various extension methods for type string.
Inherited Members
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public static class StringExtensions
Methods
View SourceConcat(ReadOnlySpan<string?>, MemoryAllocator<char>?)
Concatenates multiple strings.
Declaration
public static MemoryOwner<char> Concat(ReadOnlySpan<string?> values, MemoryAllocator<char>? allocator)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<string> | values | An array of strings. |
| MemoryAllocator<char> | allocator | The allocator of the concatenated string. |
Returns
| Type | Description |
|---|---|
| MemoryOwner<char> | A buffer containing characters from the concatenated strings. |
Exceptions
| Type | Condition |
|---|---|
| OutOfMemoryException | The concatenated string is too large. |
Reverse(string?)
Reverse string characters.
Declaration
public static string? Reverse(this string? str)
Parameters
| Type | Name | Description |
|---|---|---|
| string | str |
Returns
| Type | Description |
|---|---|
| string | The string in inverse order of characters. |
Substring(string, Range)
Extracts substring from the given string.
Declaration
public static string Substring(this string str, Range range)
Parameters
| Type | Name | Description |
|---|---|---|
| string | str | |
| Range | range | The range of substring. |
Returns
| Type | Description |
|---|---|
| string | The part of the receiver string extracted according to the supplied range. |
Remarks
This method if useful for .NET languages without syntactic support of ranges.
TrimLength(string?, int)
Trims the source string to specified length if it exceeds it.
If source string is less that maxLength then the source string returned.
Declaration
public static string? TrimLength(this string? str, int maxLength)
Parameters
| Type | Name | Description |
|---|---|---|
| string | str | |
| int | maxLength | Maximum length. |
Returns
| Type | Description |
|---|---|
| string | Trimmed string value. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|