In general, AsSpan is faster than Substring in C#. This is because AsSpan returns a span (a lightweight structure that represents a contiguous region of memory) that refers to a portion of the original string, whereas Substring creates a new string o...

Markdown supported · ⌘↵ to post
Francesco Sessanta
Are you sure about the article content? did you try the code?
Using AsSpan: 306ms Using Substring: 36ms