ArrayExtensions.Tokenize<T>(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 T
array instance using a specified separator.
This extension should be used directly within a foreach
loop:
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 T[] array, T separator) where T : IEquatable<T>;
static member Tokenize : '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)) (array As T(), separator As T) As SpanTokenizer(Of T)
Type Parameters
- T
The type of items in the T
array to tokenize.
Parameters
- array
- T[]
The source T
array to tokenize.
- separator
- T
The separator T
item to use.
Returns
A wrapper type that will handle the tokenization for array
.
Remarks
The returned SpanTokenizer<T> value shouldn't be used directly: use this extension in a foreach
loop.