1.查询所有的偶数

            int[] str = { , , , , , , , , , , , ,  };
var elist = from s in str
where s % ==
select s;
foreach (int i in elist)
{
Console.WriteLine("偶数有:{0}", i);
}
Console.ReadKey();

2.查询所有的偶数 从大到小排序

            int[] str = { , , , , , , , , , , , ,  };
var elist = from s in str
where s % ==
orderby s descending ////查询所有偶数并倒序排序,就是从大到小排序。
select s;
foreach (int i in elist)
{
Console.WriteLine("偶数有:{0}", i);
}

3.查询对象结果投影一个新的对象

    class Student
{
public string name { get; set; }
public string sex { get; set; }
public int age { get; set; }
} List<Student> list = new List<Student>()
{
new Student(){name=@"haha",sex="女",age=},
new Student(){name=@"hehe",sex="女",age=},
new Student(){name=@"heihei",sex="男",age=}
};
//var stu = from s in list
// where s.age > 10
// select s;
//foreach (var bb in stu)
//{
// Console.WriteLine("{0},{1},{2}", bb.name, bb.age, bb.sex);
//}
//将查询结果直接放入一个新的对象
var stu = from s in list
where s.age >
select new { Newname = s.name, Newsex = s.sex, Newage = s.age };
foreach (var bb in stu)
{
Console.WriteLine("{0},{1},{2}", bb.Newname, bb.Newage, bb.Newsex);
}

4.获取集合对象的,长度大于7对象。

            string[] arr = { "qwewrtyywe", "asdfghkl", "zxcvbnm", "abcqqqqqq" };
IEnumerable<string> str = from s in arr
where s.Length >
select s;
foreach (var ab in str)
{
Console.WriteLine(ab);
}

最新文章

  1. iOS开发之手势识别
  2. Windows平台下Git服务器搭建
  3. 内存对齐 和 sizeof小结
  4. 7、SQL Server索引、表压缩
  5. APICloud支持Atom编辑器,并建立开发工具核心库
  6. html dom的加载
  7. 15 Linux Split and Join Command Examples to Manage Large Files--reference
  8. 【BZOJ3439】 Kpm的MC密码 (TRIE+主席树)
  9. Google Web Toolkit (GWT)怎么制作多个用户界面
  10. 单服务器防护linux iptables脚本
  11. 目前比较流行的Python科学计算发行版
  12. thinkphp 实现微信公众号开发(一)
  13. 转:WebDriver进行屏幕截图
  14. spring调用mongodb
  15. 2017 CCPC 哈尔滨站 HDU 6242
  16. 前端学习历程--http与https
  17. jupyter notebook的安装与基本操作
  18. linux source code search
  19. 解决无法安装Microsoft .Net Framework 3.5
  20. React 懒加载组件

热门文章

  1. Node + Redis 实现分布式Session方案(转载)
  2. P2P原理(转)
  3. MySQL插入去重命令_REPLACE INTO
  4. c#高级编程第七版 学习笔记 第二章 核心c#
  5. [C++ Primer Plus] 第3章、处理数据(二)课后习题
  6. vue搭建前端相关命令
  7. 05. .stop、.prevent、.capture、.self、.once、
  8. 【转载】Selenium WebDriver的简单操作说明
  9. 20190316xlVba_设置行高的改进方案
  10. FileProvider 添加二级目录