KGy SOFT

SpanExtensions Class

KGy SOFT Core Libraries Help
Provides extension methods for Span and ReadOnlySpan types.
Inheritance Hierarchy

SystemObject
  KGySoft.CoreLibrariesSpanExtensions

Namespace:  KGySoft.CoreLibraries
Assembly:  KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 5.4.0
Syntax

public static class SpanExtensions

The SpanExtensions type exposes the following members.

Methods

  NameDescription
Public methodStatic memberParse(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.
Public methodStatic memberParseT(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.
See the Remarks section for details.
Public methodStatic memberRead
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.
Public methodStatic memberReadLine
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.
Public methodStatic memberReadToSeparator(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.
Public methodStatic memberReadToSeparator(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.
Public methodStatic memberReadToSeparator(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.
Public methodStatic memberReadToWhiteSpace
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.
Public methodStatic memberRemoveQuotes(ReadOnlySpanChar)
Extracts content of a single or double quoted string.
Public methodStatic memberRemoveQuotes(SpanChar)
Extracts content of a single or double quoted string.
Public methodStatic memberToEnumTEnum
Tries to convert the specified ReadOnlySpan<char> to an Enum value of TEnum type. No string allocation occurs when using this method.
Public methodStatic memberTryParse(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.
Public methodStatic memberTryParse(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.
Public methodStatic memberTryParseT(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.
Public methodStatic memberTryParseT(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.
Top
Remarks

Note Note
This class is available only in .NET Core 3.0/.NET Standard 2.1 and above.
See Also

Reference