How would an implementation of a SubstringFromStart
method look like when Span<T>
should be leveraged? Assuming substringLength <= input.Length
:
ReadOnlySpan<char> span = input.AsSpan().Slice(0, substringLength);
return new string(span.ToArray());
Is this the way to go? Is there a better, more concise way than new string(span.ToArray())
?