/ Published in: C#
These are statements to pull all the matching values (123) from the List.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
List<string> testList = new List<string>(){"123","456","789","123","456","789","123","456","789","123","456","789","123","456","789"}; Lambda List<string> test = testList.Where(v => v == "123").ToList(); Linq List<string> test = (from x in testList where x == "123" select x).ToList(); foreach (var num in test) { Console.WriteLine(num); } Console.ReadLine(); Results: "123" "123" "123" "123" "123"