SpanExtensions Class

Provides extension methods for SpanT and ReadOnlySpanT types.

Definition

Namespace: KGySoft.CoreLibraries
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 7.0.0-rc.1
C#
public static class SpanExtensions
Inheritance
Object    SpanExtensions

Remarks

  Note

This class is available only in .NET Core 2.1/.NET Standard 2.1 and above.

Methods

Parse(ReadOnlySpanChar, Type, CultureInfo) Parses an object from a ReadOnlySpan<char> value. Firstly, it tries to parse the type natively. If type cannot be parsed natively but the type has a TypeConverter or a registered conversion that can convert from string, then the type converter or conversion will be used.
See the Remarks section of the ParseT(ReadOnlySpanChar, CultureInfo) overload for details.
ParseT(ReadOnlySpanChar, CultureInfo) Parses an object of type T from a String represented by a ReadOnlySpan<char> value. Firstly, it tries to parse the type natively. If T cannot be parsed natively but the type has a TypeConverter or a registered conversion that can convert from string, then the type converter or conversion will be used.
Read Advances the specified rest parameter consuming up to maxLength characters and returns the consumed part. If rest started with a new line before the call, then an empty span is returned. If the whole ReadOnlySpan<char> has been processed, then rest will be ReadOnlySpan<char>.Empty after returning.
ReadLine Advances the specified rest parameter after the current line and returns the consumed part without the newline character(s). If rest started with a new line before the call, then an empty span is returned. If the whole ReadOnlySpan<char> has been processed, then rest will be ReadOnlySpan<char>.Empty after returning.
ReadToSeparator(ReadOnlySpanChar, Char) Advances the specified rest parameter after the next separator character and returns the consumed part without the separator. If the first character of rest was a separator before the call, then an empty span is returned. If the whole ReadOnlySpan<char> has been processed, then rest will be ReadOnlySpan<char>.Empty after returning.
ReadToSeparator(ReadOnlySpanChar, Char) Advances the specified rest parameter after the next separator and returns the consumed part without the separator. If rest started with one of the separators before the call, then an empty span is returned. If the whole ReadOnlySpan<char> has been processed, then rest will be ReadOnlySpan<char>.Empty after returning.
ReadToSeparator(ReadOnlySpanChar, ReadOnlySpanChar) Advances the specified rest parameter after the next separator and returns the consumed part without the separator. If rest started with separator before the call, then an empty span is returned. If the whole ReadOnlySpan<char> has been processed, then rest will be ReadOnlySpan<char>.Empty after returning.
ReadToWhiteSpace Advances the specified rest parameter after the next whitespace character and returns the consumed part without the whitespace. If the first character of rest was a whitespace before the call, then an empty span is returned. If the whole ReadOnlySpan<char> has been processed, then rest will be ReadOnlySpan<char>.Empty after returning.
RemoveQuotes(ReadOnlySpanChar) Extracts content of a single or double quoted string.
RemoveQuotes(SpanChar) Extracts content of a single or double quoted string.
ToEnumTEnum Tries to convert the specified ReadOnlySpan<char> to an Enum value of TEnum type. No string allocation occurs when using this method.
TryParse(ReadOnlySpanChar, Type, Object) Tries to parse an object of type type from a ReadOnlySpan<char> value. Firstly, it tries to parse the type natively. If type cannot be parsed natively but the type has a TypeConverter or a registered conversion that can convert from string, then the type converter or conversion will be used.
See the Remarks section of the ParseT(ReadOnlySpanChar, CultureInfo) method for details.
TryParse(ReadOnlySpanChar, Type, CultureInfo, Object) Tries to parse an object of type type from a ReadOnlySpan<char> value. Firstly, it tries to parse the type natively. If type cannot be parsed natively but the type has a TypeConverter or a registered conversion that can convert from string, then the type converter or conversion will be used.
See the Remarks section of the ParseT(ReadOnlySpanChar, CultureInfo) method for details.
TryParseT(ReadOnlySpanChar, T) Tries to parse an object of type T from a ReadOnlySpan<char> value. Firstly, it tries to parse the type natively. If T cannot be parsed natively but the type has a TypeConverter or a registered conversion that can convert from string, then the type converter or conversion will be used.
See the Remarks section of the ParseT(ReadOnlySpanChar, CultureInfo) method for details.
TryParseT(ReadOnlySpanChar, CultureInfo, T) Tries to parse an object of type T from a ReadOnlySpan<char> value. Firstly, it tries to parse the type natively. If T cannot be parsed natively but the type has a TypeConverter or a registered conversion that can convert from string, then the type converter or conversion will be used.
See the Remarks section of the ParseT(ReadOnlySpanChar, CultureInfo) method for details.

See Also