StringExtensions.Tokenize(String, Char) Method

Definition

Tokenizes the values in the input String instance using a specified separator. This extension should be used directly within a foreach loop:

string 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<char> Tokenize (this string text, char separator);
static member Tokenize : string * char -> Microsoft.Toolkit.HighPerformance.Enumerables.ReadOnlySpanTokenizer<char>
<Extension()>
Public Function Tokenize (text As String, separator As Char) As ReadOnlySpanTokenizer(Of Char)

Parameters

text
String

The source String to tokenize.

separator
Char

The separator character to use.

Returns

A wrapper type that will handle the tokenization for text.

Remarks

The returned ReadOnlySpanTokenizer<T> value shouldn't be used directly: use this extension in a foreach loop.

Applies to