ReadOnlySpanExtensions.Tokenize<T>(ReadOnlySpan<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 ReadOnlySpan<T> instance using a specified separator.
This extension should be used directly within a foreach
loop:
ReadOnlySpan<char> text = "Hello, world!";
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.ReadOnlySpanTokenizer<T> Tokenize<T> (this ReadOnlySpan<T> span, T separator) where T : IEquatable<T>;
static member Tokenize : ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> * 'T -> Microsoft.Toolkit.HighPerformance.Enumerables.ReadOnlySpanTokenizer<'T (requires 'T :> IEquatable<'T>)> (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function Tokenize(Of T As IEquatable(Of T)) (span As ReadOnlySpan(Of T), separator As T) As ReadOnlySpanTokenizer(Of T)
Type Parameters
- T
The type of items in the ReadOnlySpan<T> to tokenize.
Parameters
- span
- ReadOnlySpan<T>
The source ReadOnlySpan<T> to tokenize.
- separator
- T
The separator T
item to use.
Returns
A wrapper type that will handle the tokenization for span
.
Remarks
The returned ReadOnlySpanTokenizer<T> value shouldn't be used directly: use this extension in a foreach
loop.