Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Combining list of list as a single list
WhatsApp
Tapan Patel
Aug 01
2016
717
0
2
List<
int
>[] a =
new
List<
int
>[10];
for
(
int
i = 0; i <10; i++)
{
a[i] =
new
List<
int
>();
for
(
int
ji = 0; ji < 5; ji++)
{
a[i].Add(ji * i);
// adding some random int values to each list.
}
}
List<
int
> x = a.SelectMany(i => i.Select(j => j)).ToList();
a is a list of list of integers and by nested for loops I am creating list of list of integers. And whenever we required, by doing selectmany (Lambda), we can combine the list together.
c#
List
Up Next
Combining list of list as a single list