首页 > 代码库 > LINQ

LINQ

var racers = Formula1.GetChampions().
                Where(r => r.Wins > 15 && (r.Country == "Brazil" || r.Country == "Austria")).
                Select(r=>r);
            foreach (var item in racers)
            {
                Console.WriteLine("{0:A}",item);
            }

索引传递

var racers = Formula1.GetChampions().Where((r, index) => r.LastName.StartsWith("A") && index % 2 != 0);
            foreach (var item in racers)
            {
                Console.WriteLine("{0:A}", item);
            }

LINQ