List<T>Distinct 过滤
public class TestDuplicateDefine : IEqualityComparer<student>
{
public bool Equals(student x, student y)
{
return x.name == y.name;
} public int GetHashCode(student obj)
{
return obj.ToString().GetHashCode();
}
} public class student
{
public string name { get; set; }
public int id { get; set; }
}
private void button1_Click(object sender, EventArgs e)
{
List<student> list = new List<student>();
list.Add(new student { name = "", id = });
list.Add(new student { name = "", id = });
list.Add(new student { name = "", id = });
list.Add(new student { name = "", id = }); List<student> aa = list.Distinct(new TestDuplicateDefine()).ToList();
}
List<T>Distinct 过滤的更多相关文章
- asp.net通过distinct过滤集合(list)中重复项的办法
/// <summary> /// 权限Distinct比较器 /// </summary> public class PermissionIdComparer : IEqua ...
- 当匿名类型遇上Distinct
首先定义一个简单类,并重写ToString方法. public class CommidityFilter { public string Property { get; set; } public ...
- Distinct删除重复数据时 自定义的方法比较【转】
最近项目中在用Linq Distinct想要将重复的资料去除时,发现它跟Any之类的方法有点不太一样,不能很直觉的在呼叫时直接带入重复数据判断的处理逻辑,所以当我们要用某个成员属性做重复数据的判断时, ...
- Linq使用Distinct删除重复数据时如何指定所要依据的成员属性zz
最近项目中在用Linq Distinct想要将重复的资料去除时,发现它跟Any之类的方法有点不太一样,不能很直觉的在呼叫时直接带入重复数据判断的处理逻辑,所以当我们要用某个成员属性做重复数据的判断时, ...
- 终于等到你:CYQ.Data V5系列 (ORM数据层)最新版本开源了
前言: 不要问我框架为什么从收费授权转到免费开源,人生没有那么多为什么,这些年我开源的东西并不少,虽然这个是最核心的,看淡了就也没什么了. 群里的网友:太平说: 记得一年前你开源另一个项目的时候我就说 ...
- T-sql语句查询执行顺序
前言 数据库的查询执行,毋庸置疑是程序员必备技能之一,然而数据库查询执行的过程绚烂多彩,却是很少被人了解,今天哥哥要带你装逼带你飞,深入一下这sql查询的来龙去脉,为查询的性能优化处理打个基础,或许面 ...
- [译]RxJS 5.X基础篇
欢迎指错与讨论 : ) 当前RxJS版本:5.0.0-beta.10.更详细的内容尽在RxJS官网http://reactivex.io/rxjs/manual/overview.html.文章比较长 ...
- oracle 学习笔记(三)
1. SQL(基础查询) 1.1. 基本查询语句 1.1.1. FROM子句 SQL查询语句的语法如下: SELECT <*, column [alias], -> FROM tabl ...
- [转载]T-SQL(MSSQL)语句查询执行顺序
注意:笔者经过实验和查阅资料,已在原作基础上做了部分更改.更改不代表原作观点,查看原作请点击下方链接. 原文出处: 作者:张龙豪 链接:http://www.cnblogs.com/knowledge ...
随机推荐
- phpstorm使用zen coding 快速编辑补全html/css代码
百科定义: 使用仿CSS选择器的语法来快速开发HTML和CSS ——由Sergey Chikuyonok开发. Zen Coding由两个核心组件组成:一个缩写扩展器(缩写为像CSS一样的选择器)和上 ...
- BZOJ4426 :最大生产率(贪心+决策单调性DP)
题意:给出N个人,现在让你分P组,每组的工作效率是最小结束时间-最大开始时间,要求每一组的效率的正数,求最大效率和.N<1000 思路: 把包含至少一个其他的分到A组:否则到B组. A组的要么单 ...
- http解析过程
HTTP协议定义Web客户端如何从Web服务器请求Web页面,以及服务器如何把Web页面传送给客户端.HTTP协议采用了请求/响应模型.客户端向服务器发送一个请求报文,请求报文包含请求的方法.URL. ...
- Arcgis API本地化
①将API文件夹复制到该目录下C:\Program Files\ArcGIS\Server\framework\runtime\tomcat\webapps ②打开API文件夹中的init.js文件( ...
- js 自定义滚动条
http://visugar.com/2017/08/18/20170818CustomScroll/ chrome浏览器 https://www.cnblogs.com/yclblog/p/6 ...
- 实验吧—隐写术——WP之 SB!SB!SB!
我们先打开解题链接,里面是一张愤怒的小鸟里的小猪~ 既然这是隐写题,那么肯定要把图片下载下来进行分析咯~ 下载下来之后,我们看到题目中提示:LSB 什么是LSB? LSB(Least Signific ...
- Two Sum II - Input array is sorted
Given an array of integers that is already sorted in ascending order, find two numbers such that the ...
- 【BZOJ2820】ygy的gcd
不知道为什么不想写总结,只是(因为是用别人的权限号交的所以)屯一个代码 #include<iostream> #include<cstdio> #include<algo ...
- What's New In Zeebe: Scaling Zeebe, New Client APIs, Faster Requests, Timestamps, NodeJS Client, and Default Topic is Back!
Written by Daniel Meyer on May 16 2018 in the What's New In Zeebe category. Welcome to the first-eve ...
- TCP/IP option data aligement issue cause system broken
1 Problem Description The field reports show that xxx panel will lockup and then reboot while d ...