首页 > 技术文章 > C# 关于LINQ基础随笔

xiong950413 2018-12-26 17:16 原文

使用LINQ查询int型数组

static void Main(){
    int[] number={2,12,5,15};//数据源
    IEnumberable<int> lownums=  //定义并存储查询
                from n in number
                where n < 10
                select n;
foreach(var x in lownums){   //执行查询
       Console.Write("{0}",x);

}
}                

输出:

2,5

 

推荐阅读