How to convert C # string to Span <char>? (Span <T>)
2 answers
You need to install the System.Memory NuGet package .
There are extension methods for strings called .AsSpan () or .AsReadOnlySpan () to convert the string to the corresponding Span <T>.
Example:
Span<char> mySpan = "My sample source string".AsSpan();
ReadOnlySpan<char> myReadOnlySpan = "My read only string".AsReadOnlySpan();
Source: MSDN Channel 9 "C # 7.2: Understanding Span" (around the 6-minute mark)
+8