Skip to content

Instantly share code, notes, and snippets.

@divayht
Created December 17, 2012 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save divayht/4317555 to your computer and use it in GitHub Desktop.
Save divayht/4317555 to your computer and use it in GitHub Desktop.
public static T[] ConcatArrays<T>(params T[][] list)
{
var result = new T[list.Sum(a => a.Length)];
int offset = 0;
for (int x = 0; x < list.Length; x++)
{
list[x].CopyTo(result, offset);
offset += list[x].Length;
}
return result;
}
int[] a = new int[] { 1, 2, 3 };
int[] b = new int[] { 4, 5, 6 };
int[] c = new int[] { 7, 8 };
var y = ConcatArrays(a, b, c);
@oyo2528
Copy link

oyo2528 commented Dec 21, 2022

.Sum
where it from?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment