Show / Hide Table of Contents

Class StringExtensions

Represents various extension methods for type string.

Inheritance
object
StringExtensions
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public static class StringExtensions

Methods

View Source

Concat(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.

View Source

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.

View Source

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.

View Source

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

maxLength is less than zero.

  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾