I have read this question to get first char of the string. Is there a way to get the first n number of characters from a string in C#?
This is how you do it in 2020:
var s = "ABCDEFGH";
var first5 = s.AsSpan(0, 5);
A Spanstring requires a conversion:
Console.WriteLine(first5.ToString());
Though, these days many .NET APIs allow for spans. Stick to them if possible!
Note: If targeting .NET Framework add a reference to the System.Memory package, but don't expect the same superb performance.