Class StringExtensions
- Namespace
- LfrlAnvil.Extensions
- Assembly
- LfrlAnvil.Core.dll
Contains string extension methods.
public static class StringExtensions
- Inheritance
-
StringExtensions
- Inherited Members
Methods
AsSegment(string, int)
Creates a new StringSegment instance from the given string and startIndex.
[Pure]
public static StringSegment AsSegment(this string source, int startIndex)
Parameters
sourcestringSource string.
startIndexintIndex of the first character that should be included in the segment.
Returns
- StringSegment
New StringSegment instance.
Exceptions
- ArgumentOutOfRangeException
When
startIndexis less than 0.
AsSegment(string, int, int)
Creates a new StringSegment instance from the given string,
startIndex and length.
[Pure]
public static StringSegment AsSegment(this string source, int startIndex, int length)
Parameters
sourcestringSource string.
startIndexintIndex of the first character that should be included in the segment.
lengthintLength of the segment.
Returns
- StringSegment
New StringSegment instance.
Exceptions
- ArgumentOutOfRangeException
When
startIndexis less than 0 or whenlengthis less than 0.
Decode(Encoding, ReadOnlySpan<byte>)
Attempts to decode all the bytes in the specified byte span into a string.
[Pure]
public static Result<string> Decode(this Encoding encoding, ReadOnlySpan<byte> bytes)
Parameters
encodingEncodingEncoding used for decoding the byte span.
bytesReadOnlySpan<byte>A byte span to decode to a string.
Returns
Reverse(string)
Reverses the given string.
[Pure]
public static string Reverse(this string source)
Parameters
sourcestringSource string.