Problem with List<IEnumerable<string>>

Hi,

Why do I get a wrong result for this simple code in LINQPad?

List toSearch= new List{100,199,95}; List assets = new List{"95873","95950","95935","95942","105019","95938","199999","97490","100442","100167","100167","95873"}; List> list = new List>(); foreach ( var n in toSearch) { IEnumerable query = (from asset in assets where asset.Contains(n.ToString()) select asset); list.Add(query); } foreach (var v in list) Console.WriteLine(v.Count());
Output:
6
6
6

The correct output would be:
3
1
6

LINQPad v.4.42.01
.Net 4.0

Thanks,

Comments

Sign In or Register to comment.