合并多个List<T>类型并通过LINQ按指定属性排序
后台CS代码:
namespace WebFormTest.TestCollect
{
public partial class ListTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
List<Person> list1 = new List<Person>();
list1.Add(new Person() { Age = , Name = "张三", Time = Convert.ToDateTime("2013/12/20 13:20") });
list1.Add(new Person() { Age = , Name = "李四", Time = Convert.ToDateTime("2013/12/20 14:20") });
list1.Add(new Person() { Age = , Name = "王五", Time = Convert.ToDateTime("2013/12/20 13:40") }); List<Person> list2 = new List<Person>();
list2.Add(new Person() { Age = , Name = "张三2", Time = Convert.ToDateTime("2013/12/20 13:20") });
list2.Add(new Person() { Age = , Name = "李四2", Time = Convert.ToDateTime("2013/12/20 14:20") });
list2.Add(new Person() { Age = , Name = "王五2", Time = Convert.ToDateTime("2013/12/20 13:40") }); list1 = list1.Concat(list2).ToList(); //合并多个list<T> list1 = list1.OrderByDescending(i => i.Time).ToList(); //降序排列
//list.OrderBy(i => i.Time);升序排列 Repeater1.DataSource = list1;
Repeater1.DataBind();
}
} public class Person
{
private int age; public int Age
{
get { return age; }
set { age = value; }
}
private string name; public string Name
{
get { return name; }
set { name = value; }
} private DateTime time; public DateTime Time
{
get { return time; }
set { time = value; }
} }
}
前台代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ListTest.aspx.cs" Inherits="WebFormTest.TestCollect.ListTest" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<tr>
<td>
<%#Eval("Age") %>
</td>
<td>
<%#Eval("Name") %>
</td>
<td>
<%#Eval("Time") %>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</div>
</form>
</body>
</html>
效果展示:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAp8AAACUCAIAAABa0tW1AAAOAUlEQVR4nO3dW5qbOhCFUQ8u880QfR46cTgI7SpdMKrSvx7ydYNVluyWNuBLXm8AAJDL6+kOAACAyUh3AACyId0BAMiGdAcAIBvSHQCAbKrp/hsAAMSk0v1XFpnGAjyCSQTEYqT76KWBNeixvF68PAEYMi0IwA5Id9IdsGVaEIAdbJfuL59j844mQDKLLAjTJxozF1ltl+4nnmw+7vX8DOSzwoKQMtpX6ANSstM9wUlqbWH6Gcvx30ukO1C7AFbeUi8Uuon/OPuOgiPj8t9L095aHyb28I4hYwWudP9if25xme6fcZU/1G7p/BnIp7YgiF9r2XmqrAuemt9XsHtcgpmOTdl5Uw/nFsQ6dkx3MavNxYJ0x5486W4GrWeL5yD7joKD4xJ0B6ake18PRavBIWMFe6W750i/vBnpDtyX7s69ydJd5Ojbt1I19dC/9DkLYn3edDcvMa2sdmW+dNm89hdPumMf+uWty1+dWz7bO6Jd79J352+1SLqP9JB035Ar3aPHmOftvp7lo3aWH/e4B3C6O9313mTpPr6iTukh6Z6bne7nBgGfYzPdPVO9bxEBcignUV+WmzNl1gGB2NVacLV0n9VD0j23vdL98mp8zae559Q84sMC+JVvTS1vs1S6953ud49LqNXsu/I3sYeke27e193/NQj4HA9+E23fPAEyOX3e/fI2U87my1870l3nd+sBwR3pPrcU6Y4S6e5K96ZzfSCf8c+71zb6C16aVXBwXE09NPdeLikjPaytUaLVyJCxAteV+egZ5vmuOoFzd8D/5ZXm9nKvrlbrUq2g7qFI975xCc6CtQdkYg9Fz81WTUPGOppfd49If8/8lzsDRPTIgjB9ejLfsY/d0x2AB5MIiIV0B2BjEgGxkO4AbEwiIBaV7gAAICLj3D2HTGMBHsEkAmLhyjxvowVsmRYEYAekO+kO2DItCMAOtkv38hshLh2bdzQBkllkQeAT8IDTdul+4snm1/+/Bsv8GchnhQUhZbSv0Aek5Pqe+egnqbWF6XX4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BA47uTne9N2W6d5SqterrIeme23bp/vGFdI/7iAEnngVhPN07mky5mN/agYnp3lrN2R/SHaS78fJVt7gPF1A6TaLaq8UdWwabzD3d7x6XMDfdJ/aQdM+NdPe+B6dJ3McKuKTfvFLb3rHF84KxLih6qAuOjEtoHXJTKeddtLYi3RMg3f/8UDuDf7Uom5e/AhGNf969ttFf8NKsgoPjmtjDd+UQZKSHtWMa0WpkyFiBK90vMyyQ8rSjzO9Tk5Fh1lIfiKv2XzHVgkRsL/fqarUu1QrqHtYKdo9L6Bvyu74odfdQ9Nxs1TRkrKPh3D0u/ZIhf7uA6ZEFYfrcZLJjHzumO4BWTCIgFtIdgI1JBMRCugOwMYmAWFS6AwCAiKrp/gsAAMTEO0gBAMiGdAcAIBvSHQCAbEh3AACyId0BAMiGdAcAIBvSHQCAbEh3AACyId0BAMiGdAcAIBvSHQCAbEh3AACyId0BAMiGdAcAIJv/AKsOYih57xeJAAAAAElFTkSuQmCC" alt="" />
合并多个List<T>类型并通过LINQ按指定属性排序的更多相关文章
- 分析器错误消息: 类型“test.test.testx”不明确: 它可能来自程序集“F:\testProject\bin\test.test.DLL”或程序集“F:\testProject\bin \testProject.DLL”。请在类型名称中显式指定程序集。
问题描述: RT 分析器错误消息: 类型“test.test.testx”不明确: 它可能来自程序集“F:\testProject\bin\test.test.DLL”或程序集“F:\testProj ...
- 与元素类型 "item" 相关联的 "name" 属性值不能包含 '<' 字符。
Android Studio 打包时,报错: 与元素类型 "item" 相关联的 "name" 属性值不能包含 '<' 字符. 这个问题自己百度也没有发现 ...
- C# 核心语法-反射(反射类型、方法、构造函数、属性,实现可配置可扩展,完成数据库访问类反射封装)
反射是.NET中的重要机制,通过反射,可以在运行时获得程序或程序集中每一个类型(包括类.结构.委托.接口和枚举等)的成员和成员的信息.有了反射,即可对每一个类型了如指掌.另外我还可以直接创建对象,即使 ...
- 类型“Observable<Response>”上不存在属性“map”
出错提示: angular2 Property 'map' does not exist on type 'Observable<Response>' 类型“Observable<R ...
- C#—反射(反射类型、方法、构造函数、属性、实现可配置可扩展、数据库访问类反射封装)
反射是.NET中的重要机制,通过反射,可以在运行时获得程序或程序集中每一个类型(包括类.结构.委托.接口和枚举等)的成员和成员的信息.有了反射,即可对每一个类型了如指掌.另外我还可以直接创建对象,即使 ...
- 合并多个cv::Mat类型,即合并多个图片的接口
1. cv::Mat get_merage_image(cv::Mat cur_frame) { cv::Mat image_one=cur_frame; cv::Mat image_two=cur_ ...
- PAT 基础编程题 4-11 求自定类型元素序列的中位数(希尔排序)
4-11 求自定类型元素序列的中位数 (25分) 本题要求实现一个函数,求N个集合元素A[]的中位数,即序列中第\lfloor N/2 +1\rfloor⌊N/2+1⌋大的元素.其中集合元素的类型 ...
- 1.4.2 solr字段类型--(1.4.2.7)字段属性使用案例
1.4.2 solr字段类型 (1.4.2.1) 字段类型定义和字段类型属性. (1.4.2.2) solr附带的字段类型 (1.4.2.3) 使用货币和汇率 (1.4.2.4) 使用Dates(日期 ...
- JavaScript类型检测, typeof操作符与constructor属性的异同
*#type.js function Person(name, age) { this.name = name; this.age = age; } var d = {an: 'object'}; v ...
随机推荐
- XML中五个转义字符
字符:<,>,&,",© HTML对应的转移字符:< >&"© XML(只有5个)对应的转义字符: < >& " ...
- [Java] 03 String获取文件后缀名,判断文件是否合法
package test.string; import java.util.Arrays; import java.util.List; public class GetFileType { priv ...
- [ActionScript 3.0] 自定义顶级类
为了结合FlashBuilder编译参数,达到发布项目时不编译trace代码方便,写一个顶级类: package { public function tracing(...args):void { C ...
- crm plugin 未能加载文件或程序集“xxxx,”或它的某一个依赖项。系统找不到指定的文件。
plugin运行出错. 1 plugin文件如果是 注册到disk,应该是注册到 C:\Program Files\Microsoft Dynamics CRM\Server\bin\assembl ...
- Java如何获取文件编码格式
1:简单判断是UTF-8或不是UTF-8,因为一般除了UTF-8之外就是GBK,所以就设置默认为GBK. 按照给定的字符集存储文件时,在文件的最开头的三个字节中就有可能存储着编码信息,所以,基本的原 ...
- JqGrid单选
You have to do some more stuff: 1. Set multiboxonly to true and multiselect to true 2. Define the ev ...
- Angularjs过滤器的开发.
先上代码. <!DOCTYPE html> <html ng-app="FilterModule"> <head lang="en" ...
- Matla学习:figure+axes+plot
function fig = SetDrawParam() %.获得屏幕尺寸 figpos = , 'ScreenSize');%获得屏幕尺寸,单位像素 %.设置坐标系在画布中的位置,针对不同尺寸或不 ...
- Hadoop 2.6.0动态添加节点
文章出自:http://my.oschina.net/leoleong/blog/477508 本文主要从基础准备,添加DataNode和添加NodeManager三个部分详细说明在Hadoop2.6 ...
- 【转】特殊权限控制之SUID、SGID、Sticky
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://soysauce93.blog.51cto.com/7589461/1715583 ...