using System.Runtime.InteropServices;
public static string Marshal_Span(string Content)
Span<char> chars = MemoryMarshal.CreateSpan(ref MemoryMarshal.GetReference(Content.AsSpan()), Content.Length);
for (int i = 0; i < chars.Length; i++)
public static void Main()
"Hello World! Add new line. Ok. Substring allocates a new string object on the heap and performs a full copy of the extracted text." +
"String manipulation is a performance bottleneck for many programs. Many APIs that accept strings also have overloads that accept a ReadOnlySpan<System.Char> argument." +
"When such overloads are available, you can improve performance by calling AsSpan instead of Substring.";
Console.WriteLine(Marshal_Span(Content));