I want to do this in LINQ:
public static void ConcatAt(this string[] items, string[] others, int at)
{
for (int i = 0; i < others.Length && at < items.Length; i++, at++) {
items[at] = others[i];
}
}
Usage:
string[] groups = { "G1", "G2", "G3" };
string[] names = new string[groups.Length + 1];
names[0] = "Choose";
names.ConcatAt(groups, 1);
foreach (var n in names)
Console.WriteLine(n);
/*
Choose
G1
G2
G3
*/
String was just an example, could be anything though.
So is there a LINQ method that does this?
Doing a names = names.Concat(groups).ToArray(); will include the empty strings that's in names so if I print names I'd get:
/*
Choose
G1
G2
G3
*/
Thanks.
names = names.Concat(groups).ToArray();? Is the index a requirement .. ?names, I would get "Choose", "", "", "", G1", etc.