METHOD
Span<T>.TryCopyTo
Copies all elements, including overlapping ranges, when the destination is sufficiently long. Returns false without copying if it is too short.
Formal Syntax & Structure
csharp syntaxcsharp
source.TryCopyTo(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}; int[] b={9}; Console.WriteLine(a.AsSpan().TryCopyTo(b)); // False