METHOD
Span<T>.CopyTo
Copies the source elements into a sufficiently long destination. Overlap is supported as if the original elements were saved first. Throws ArgumentException if the destination is too short.
Formal Syntax & Structure
csharp syntaxcsharp
source.CopyTo(destination)Working Example
Example Snippetcsharp
using System;using System.IO;using System.Collections.Generic;using System.Buffers;using System.Buffers.Binary;using System.Runtime.CompilerServices;using System.Threading;int[] a={1,2,3}; a.AsSpan(0,2).CopyTo(a.AsSpan(1)); Console.WriteLine(string.Join(",",a)); // 1,1,2