SpanExtensions.Tokenize<T>(Span<T>, T) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Tokenizes the values in the input Span<T> instance using a specified separator.
This extension should be used directly within a foreach
loop:
Span<char> text = "Hello, world!".ToCharArray();
foreach (var token in text.Tokenize(','))
{
// Access the tokens here...
}
The compiler will take care of properly setting up the foreach
loop with the type returned from this method.
public static Microsoft.Toolkit.HighPerformance.Enumerables.SpanTokenizer<T> Tokenize<T> (this Span<T> span, T separator) where T : IEquatable<T>;
static member Tokenize : Span<'T (requires 'T :> IEquatable<'T>)> * 'T -> Microsoft.Toolkit.HighPerformance.Enumerables.SpanTokenizer<'T (requires 'T :> IEquatable<'T>)> (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function Tokenize(Of T As IEquatable(Of T)) (span As Span(Of T), separator As T) As SpanTokenizer(Of T)
Type Parameters
- T
The type of items in the Span<T> to tokenize.
Parameters
- separator
- T
The separator T
item to use.
Returns
A wrapper type that will handle the tokenization for span
.
Remarks
The returned SpanTokenizer<T> value shouldn't be used directly: use this extension in a foreach
loop.