C#哪里
示例
返回指定谓词对它们为真的项的子集。
List<string> trees = new List<string>{ "Oak", "Birch", "Beech", "Elm", "Hazel", "Maple" };
方法语法
//选择所有名称长度为3的树 var shortTrees = trees.Where(tree =>tree.Length== 3); //橡树,榆木
查询语法
var shortTrees = from tree in trees wheretree.Length== 3 select tree; //橡树,榆木