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 ...
随机推荐
- 机器学习: K-means 聚类
今天介绍机器学习里常见的一种无监督聚类算法,K-means.我们先来考虑在一个高维空间的一组数据集,S={x1,x2,...,xN}" role="presentation&quo ...
- 强化学习基础算法入门 【PPT】
该部分内容来自于定期的小组讨论,源于师弟的汇报. ==============================================
- DS18B20读数错误排除
描述: 同时测试了好几个板子,都接了DS18B20传感器.但,有的板子读取的DS18B20温度值正确,有的读取错误. 原因查找: 以为是有的传感器坏了,但测试后发现并不是. 又以为是DS18B20需要 ...
- [LeetCode&Python] Problem 771: Jewels and Stones
You're given strings J representing the types of stones that are jewels, and S representing the ston ...
- RNN-LSTM-GRU-BIRNN
https://blog.csdn.net/wangyangzhizhou/article/details/76651116 共三篇 RNN的模型展开后多个时刻隐层互相连接,而所有循环神经网络都有一个 ...
- The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online -C:Halting Problem(模拟)
C Halting Problem In computability theory, the halting problem is the problem of determining, from a ...
- UE4 IOS 开发之传感器输入
Iphone的传感器包括陀螺仪.加速计等. UE4提供了4个按键来收集这些传感器的3维数据.具体位置:ProjectSettings->Input. 其中Tilt数据可以反映Iphone目前的物 ...
- 03 重定向,请求转发,cookie,session
重定向: /* 之前的写法 response.setStatus(302); response.setHeader("Location", "login_success. ...
- php基础-2
php的逻辑运算 &&符号 <?php function tarcrnum() { for ($i = 0; $i <= 100; $i++) { if ($i % 2 = ...
- Python--异常处理和断言
try关键字,定义获取程序错误 except关键字,出现异常错误执行里面的代码 Exception定义错误类,Exception能获取到所有类型的错误错误,as创建错误对象名称,自动获取错误信息 #! ...