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 过滤的更多相关文章

  1. asp.net通过distinct过滤集合(list)中重复项的办法

    /// <summary> /// 权限Distinct比较器 /// </summary> public class PermissionIdComparer : IEqua ...

  2. 当匿名类型遇上Distinct

    首先定义一个简单类,并重写ToString方法. public class CommidityFilter { public string Property { get; set; } public ...

  3. Distinct删除重复数据时 自定义的方法比较【转】

    最近项目中在用Linq Distinct想要将重复的资料去除时,发现它跟Any之类的方法有点不太一样,不能很直觉的在呼叫时直接带入重复数据判断的处理逻辑,所以当我们要用某个成员属性做重复数据的判断时, ...

  4. Linq使用Distinct删除重复数据时如何指定所要依据的成员属性zz

    最近项目中在用Linq Distinct想要将重复的资料去除时,发现它跟Any之类的方法有点不太一样,不能很直觉的在呼叫时直接带入重复数据判断的处理逻辑,所以当我们要用某个成员属性做重复数据的判断时, ...

  5. 终于等到你:CYQ.Data V5系列 (ORM数据层)最新版本开源了

    前言: 不要问我框架为什么从收费授权转到免费开源,人生没有那么多为什么,这些年我开源的东西并不少,虽然这个是最核心的,看淡了就也没什么了. 群里的网友:太平说: 记得一年前你开源另一个项目的时候我就说 ...

  6. T-sql语句查询执行顺序

    前言 数据库的查询执行,毋庸置疑是程序员必备技能之一,然而数据库查询执行的过程绚烂多彩,却是很少被人了解,今天哥哥要带你装逼带你飞,深入一下这sql查询的来龙去脉,为查询的性能优化处理打个基础,或许面 ...

  7. [译]RxJS 5.X基础篇

    欢迎指错与讨论 : ) 当前RxJS版本:5.0.0-beta.10.更详细的内容尽在RxJS官网http://reactivex.io/rxjs/manual/overview.html.文章比较长 ...

  8. oracle 学习笔记(三)

    1. SQL(基础查询) 1.1. 基本查询语句 1.1.1. FROM子句 SQL查询语句的语法如下:   SELECT <*, column [alias], -> FROM tabl ...

  9. [转载]T-SQL(MSSQL)语句查询执行顺序

    注意:笔者经过实验和查阅资料,已在原作基础上做了部分更改.更改不代表原作观点,查看原作请点击下方链接. 原文出处: 作者:张龙豪 链接:http://www.cnblogs.com/knowledge ...

随机推荐

  1. Spring Boot 揭秘与实战(八) 发布与部署 - 远程调试

    文章目录 1. 依赖 2. 部署 3. 调试 4. 源代码 设置远程调试,可以在正式环境上随时跟踪与调试生产故障. 依赖 在 pom.xml 中增加远程调试依赖. <plugins> &l ...

  2. angular把echarts封装为指令(配合requirejs)

    1.在require中配置echartsjs文件 2.在directives下定义指令(定义为全局的指令,任何页面调用都可以) define(['app','echarts'],function(ap ...

  3. [转]Introduction to Learning to Trade with Reinforcement Learning

    Introduction to Learning to Trade with Reinforcement Learning http://www.wildml.com/2018/02/introduc ...

  4. e与复利

    e≍2.718 计算一个复利例子,设本金p,年利率为r,每月计算一次利息,月利息为r/12,则一年的本息一共: p(1+r/12)12=pq 当计算复利的时间间隔越来越小,根据上面极限公式,本金所乘的 ...

  5. hint不当索引,影响多表连接方式,最终导致SQL执行缓慢

    需求:一个SQL执行特别慢,无法返回结果,需要进行优化,最终返回结果即可. 一.SQL分析 二.尝试执行,观测执行计划 三.修改SQL 四.问题总结 一.SQL分析 )SQL文本,执行时间,执行用户 ...

  6. 创建文件夹c++

    linux #include <sys/types.h> #include <sys/stat.h> string filepath; mkdir(filepath.c_str ...

  7. angular file change

    AngularJs: How to check for changes in file input fields? <input type="file" onchange=& ...

  8. GitHub使用教程、注册与安装

    GitHub注册与安装 本文提供全流程,中文翻译.Chinar坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请调整网页缩放比例至200%) 1 进入GitHub官网:http ...

  9. 四则运算V1.1

    作业:https://edu.cnblogs.com/campus/nenu/SWE2017FALL/homework/997 代码:https://coding.net/u/Dawnfox/p/f4 ...

  10. sed 等相关的复习

    sed相打印两行之间的内容: sed -n '/111/,/aad/p' fuxi.txt grep -n ".*" fuxi.txt sed -n '2,9'p fuxi.txt ...