C# copy array code example
Example 1: how to copy one array value to another without reference c#
var source = new[] { "Ally", "Bishop", "Billy" };
var target = new string[4];
source.CopyTo(target, 1);
foreach (var item in target)
{
Console.WriteLine(item);
}
Example 2: clone an array c#
float[] newFloats = oldFloats.Clone() as float[];
Example 3: copy a list C#
using System;
using System.Linq;
using System.Collections.Generic;
List<string> source = new List<string>() { "A", "B", "C" };
List<string> clonedList = source.ToList();
Console.WriteLine(String.Join(",", clonedList));
Example 4: array copy c#
unsortedArray.CopyTo(unsortedArray2 , 0);