Say I have the following List<List<string>>:
List<List<string>> input=new List<List<string>>();
for (int i = 0; i < 6; i++)
{
input.Add(new List<string>());
}
input[0]=new List<string>{"David","3","Ceviche"};
input[1]=new List<string>{"Corina","10","Beef Burrito"};
input[2]=new List<string>{"David","3","Fried Chicken"};
input[3]=new List<string>{"Carla","5","Water"};
input[4]=new List<string>{"Carla","5","Ceviche"};
input[5]=new List<string>{"Rous","3","Ceviche"};
How would I find the total count of distinct strings at input[i][1]? So in this case the count is 3 because you have "3","5","10"
What I have gives me 4
int count=input.SelectMany(x => x[1]).Distinct().Count();
Selectinstead ofSelectMany. What you're doing is counting the distinct characters of the strings at position 1, which are 3, 1, 0 and 5. It does that becausestringis aIEnumerable<char>.