//definition of an array which can be inumerable
People[] peoples = new People[] {
new People("Li", "C#"),
new People("zhang", "C++"),
new People("Smith", "C++")
};
// Linq expression
IEnumerable<string> peoples_cpp =
from d in peoples
where d._language == "C++"
select d._name;
// it's counterpart first
IEnumerable<string> peoples_cpp =
peoples.Where(d => d._language == "C++").Select(d => d._name);
// it's counterpart first
Func<People, bool> filtering = d => d._language == "C++";
Func<People, string> selectPredicate = d => d._name;
IEnumerable<string> peoples_cpp =
peoples.Where(filtering).Select(selectPredicate);
People[] peoples = new People[] {
new People("Li", "C#"),
new People("zhang", "C++"),
new People("Smith", "C++")
};
// Linq expression
IEnumerable<string> peoples_cpp =
from d in peoples
where d._language == "C++"
select d._name;
// it's counterpart first
IEnumerable<string> peoples_cpp =
peoples.Where(d => d._language == "C++").Select(d => d._name);
// it's counterpart first
Func<People, bool> filtering = d => d._language == "C++";
Func<People, string> selectPredicate = d => d._name;
IEnumerable<string> peoples_cpp =
peoples.Where(filtering).Select(selectPredicate);
本文介绍如何利用C#中的LINQ表达式从一组人员数据中筛选出使用C++编程语言的开发者,并通过不同方式实现相同功能。
1万+

被折叠的 条评论
为什么被折叠?



