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. 跳过IE10安装VS2013

    @ECHO OFF :IE10HACK REG ADD "HKLM\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer" /v Ver ...

  2. Hadoop Pipeline详解[摘抄]

    最近使用公司内部的一个框架写map  reduce发现没有封装hadoop streaming这些东西,查了下pipeline相关的东西 Hadoop Pipeline详解 20. Aug / had ...

  3. filesort是通过相应的排序算法

    filesort是通过相应的排序算法,将取得的数据在max_length_for_sort_data的默认值是1024. --------------------------------------- ...

  4. [转]编译安装libevent,memcache,以及php的memcached扩展

    一 安装libevent 1.去官网http://libevent.org/ 下载最新源码,我用的是libevent-2.0.20-stable.tar.gz 2.解压到/usr/src目录 ,执行命 ...

  5. CFDebug.template

    { "AWSTemplateFormatVersion" : "2010-09-09", "Description" : "Cre ...

  6. 使用nvm安装node

    安装nvm curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash 安装node nvm ...

  7. JMeter压测Rest请求

    下载及安装 官网下载JMeter3.0: 找到bin目录下的jmeter.bat启动: 压测Rest请求 1.添加线程组 路径:右键“测试计划”->添加“Threads(Users)”-> ...

  8. fontcreator制作iconfont(包含两个教程)

    第一步 在AI中画好矢量图,或者是在PS中将纯色的图片存成PNG格式,最好是放大很多倍的纯色图片.因为导入到fontcreator中会显得很小,如果不是矢量,图片拉大后就会有锯齿状. 第二步 选中AI ...

  9. CentOS7 修改主机名(转)

    转载出处:http://www.centoscn.com/CentOS/config/2014/1031/4039.html CentOS7 时间同步:http://www.cnblogs.com/r ...

  10. delphi 一个自动控制机的硅控板检测程序,用多线程和API,没有用控件,少做改动就能用 用485开发

    一个自动控制机的硅控板检测程序,用多线程和API,没有用控件,少做改动就能用Unit CommThread; Interface Uses  Windows, Classes, SysUtils, G ...