第十二章 linq

1.索引筛选 .Where((r,index)=>r.Name.StartsWith("N"&&index%2==0))

2.类型筛选 object[] data={"你好","呵呵",1,2} 类型筛选 .OfType<string>();

2.符合筛选:

 

 

3.Linq 查询定义变量

  •    var countries=from r in Formulal.GetChampions()
  •                           group  r by r.Country into g
  •                           let count=g.Count()
  •                           orderby count descending,g.key
  •                           where count>=2
  •                           select new 
  •                           {
  •                               Country=g.Key,
  •                               Count=count
  •                           }

4.Cast ()

 

posted @ 2022-06-30 15:14  1509367191  阅读(5)  评论(0)    收藏  举报