1、Lambda表达式
List<int> array = new List<int>() { 20, 21, 22, 10, 12, 13, 14, 5, 6, 7, 8, 9 };
var filtered = (from p in array
where p >= 10
select p).OrderBy(p => p);
foreach (int p in filtered)
{
Console.WriteLine("Value = {0}", p);
}
2、Linq
List<int> array = new List<int>() { 20, 21, 22, 10, 12, 13, 14, 5, 6, 7, 8, 9 };
foreach (int p in array.Where(p => p >= 10).OrderBy(p => p))
{
Console.WriteLine("Value = {0}", p);
}