I have a list of string:
var list = new List<string>();
Data in the list is in this format A1_A2_A3, A1_A2_A3, A1_A2_A3
I want to split each element A1_A2_A3 of list by _ and store the result into List<Item>
Where Item is a class containing three properties a1, a2, a3
I want to do it using LINQ, I can do this by using loop but I'm looking for solution using LINQ Only
Here is my working:
list.Select(x => x.Split('_').Select(s => new Item()
{
a1 = x[0],
a2 = x[1],
a3 = x[2]
}))
x.Split("_")for the underscore.x.Split("_"). I've updated my question