public class Student
{
public string Name { get; set; }
public int Age { get; set; }
public Student(String _name, int _age)
{
this.Name = _name;
this.Age = _age;
}
}
public static test1()
{ List<Student> listStudent = new List<Student>();
Student s1 = new Student("xiaoming", 20);
Student s2 = new Student("Lifang", 30);
Student s3 = new Student("LIUL", 10);
Student s4 = new Student("Amie", 4);
listStudent.Add( s1);
listStudent.Add( s2);
listStudent.Add( s3);
listStudent.Add( s4); //方法一
// 构造Query 给List 排序
IEnumerable<Student> sortedStudentList =
from st in listStudent
orderby st.Age descending, st.Name ascending
select st; //将排序的结果转为新的List, 赋值给dataGridView 做数据源
List<Student> tmpList = new List<Student>();
tmpList = sortedStudentList .ToList<Student>();
this.dataGridView1.DataSource = tmpList; //方法二
IEnumerable<Student> query = listStudent.OrderBy( st=> st.Age);
tmpList = query.ToList<Student>();
this.dataGridView1.DataSource = tmpList; }

  

C# List结果集排序的更多相关文章

  1. Oracle在rownum使用结果集排序

    Oracle在rownum使用结果集排序    对于 Oracle 的 rownum 问题,非常多资料都说不支持>,>=,=,between...and,仅仅能用以上符号(<.< ...

  2. SPOJ:Lexicographically Smallest(并查集&排序)

    Taplu and Abhishar loved playing scrabble. One day they thought of inventing a new game using alphab ...

  3. [转]SQL 操作结果集 -并集、差集、交集、结果集排序

    本文转自:http://www.cnblogs.com/kissdodog/archive/2013/06/24/3152743.html 操作结果集 为了配合测试,特地建了两个表,并且添加了一些测试 ...

  4. SQL 操作结果集 -并集、差集、交集、结果集排序

    操作结果集 为了配合测试,特地建了两个表,并且添加了一些测试数据,其中重复记录为东吴的人物. 表:Person_1魏国人物 表:Person_2蜀国人物 A.Union形成并集 Union可以对两个或 ...

  5. 疯狂位图之——位图实现12GB无重复大整数集排序

    <Programming Pearls>(编程珠玑)第一章讲述了如何用位图排序无重复的数据集,整个思想很简洁,今天实践了下. 一.主要思想 位图排序的思想就是在内存中申请一块连续的空间作为 ...

  6. 转:SQL 操作结果集 -并集、差集、交集、结果集排序

    为了配合测试,特地建了两个表,并且添加了一些测试数据,其中重复记录为东吴的人物. 表:Person_1魏国人物 表:Person_2蜀国人物 A.Union形成并集 Union可以对两个或多个结果集进 ...

  7. SQL Server操作结果集-并集 差集 交集 结果集排序

    操作结果集 为了配合测试,特地建了两个表,并且添加了一些测试数据,其中重复记录为东吴的人物. 表:Person_1魏国人物 表:Person_2蜀国人物 A.Union形成并集 Union可以对两个或 ...

  8. FZU 2059 MM (并查集+排序插入)

    Problem 2059 MM Accept: 109    Submit: 484Time Limit: 1000 mSec    Memory Limit : 32768 KB  Problem ...

  9. 先对结果集排序然后做update、delete操作

    --先排序然后删除第n条数据delete from scott.emp where empno in (select empno                   from (select *    ...

随机推荐

  1. winform中button的image属性无法更改

    在开发一个winform程序的时候,界面中的button的image本来有一个贴图A.后来我觉得不合适,打算换成贴图B. 但是这时问题出现了:虽然我改成了贴图B,在IDE中的预览也是贴图B,但是每次编 ...

  2. js数组键入值push和 arr[]i]区别

    push 和 arr[i] 遍历 var arr = new Array(); $(":check").each(function(i){if(this.checked==true ...

  3. 写自己的ASP.NET MVC框架(上)

    http://www.cnblogs.com/fish-li/archive/2012/02/12/2348395.html 阅读目录 开始 ASP.NET程序的几种开发方式 介绍我的MVC框架 我的 ...

  4. 前端JavaScript规范

    前端JavaScript规范 http://www.imooc.com/article/1402 http://greengerong.com/blog/2015/05/09/qian-duan-ja ...

  5. 关于flume配置加载

    最近项目在用到flume,因此翻了下flume的代码, 启动脚本: nohup bin/flume-ng agent -n tsdbflume -c conf -f conf/配置文件.conf -D ...

  6. Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No such file or directory'

    1.根本原因在http://askubuntu.com/questions/606732/php-fatal-error-uncaught-exception-pdoexception-with-me ...

  7. CNC Fanuc 设备数据采集

    为了这个Fanuc(发那科)数控机床数据的采集也花费了不少精力,先是去供应商那里了解,基本都是代理商,没有技术支持. 在网上也有关于Fanuc的以太网Ethernet连接文档,那里面有说明,大概是开发 ...

  8. Arrays数组的常用方法

    下面代码主要说明了Arrays数组的几个常用方法(红色字体) import java.util.Scanner;import java.util.Arrays;      public class T ...

  9. div标签上下滚动

    <div id="myInfo" style={{width:'100%',height:'100%', overflow:'scroll'}}></div> ...

  10. 为什么C#中ref和out 关键字 ?

    需求假设:现需要通过一个叫Swap的方法交换a,b两个变量的值.交换前a=1,b=2,断言:交换后a=2,b=1. 现编码如下: class Program   {       static void ...