© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
37 replies
BenMcLean

❔ Combine two arrays by alternating items?

Let's imagine I have two arrays, A and B, which each have four items.
I want to make a new array C which is made up of the contents of A and B.
so
T[] c = new T[a.Length + b.Length];//8
c[0]=a[0];
c[1]=b[0];
c[2]=a[1];
c[3]=b[1];
c[4]=a[2];
c[5]=b[2];
c[6]=a[3];
c[7]=b[3];
T[] c = new T[a.Length + b.Length];//8
c[0]=a[0];
c[1]=b[0];
c[2]=a[1];
c[3]=b[1];
c[4]=a[2];
c[5]=b[2];
c[6]=a[3];
c[7]=b[3];
Except can I do this with LINQ? And for any arbitrary size?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Combine two Expression Func [Answered]
C#CC# / help
4y ago
Union? of two binary arrays
C#CC# / help
4y ago
beginner, two questions about arrays and counting?
C#CC# / help
2y ago
❔ ❔ Merging 2 arrays 1 by 1
C#CC# / help
4y ago