1.创建compare类

using DCZY.Bean;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace DCZY.Bean
{
public class HookPlanMonitorDeviceCompare : IEqualityComparer<HookPlanMonitorDeviceInfo>
{
public bool Equals(HookPlanMonitorDeviceInfo x, HookPlanMonitorDeviceInfo y)
{
if (x.Device.Name == y.Device.Name)
{
return true;
}
else
{
return false;
}
} public int GetHashCode(HookPlanMonitorDeviceInfo obj)
{
int hCode = obj.Device.Name.GetHashCode();
return hCode.GetHashCode();
}
}
}

2.调用

List<HookPlanMonitorDevice> devicecollection = devicecollection.Distinct(new HookPlanMonitorDeviceCompare()).ToList();

关于distinct的compare参数的使用的更多相关文章

  1. 【C#】详解使用Enumerable.Distinct方法去重

    Enumerable.Distinct 方法 是常用的LINQ扩展方法,属于System.Linq的Enumerable方法,可用于去除数组.集合中的重复元素,还可以自定义去重的规则. 有两个重载方法 ...

  2. C# list distinct操作

    使用代理实现对C# list distinct操作   范型在c#编程中经常使用,而经常用list 去存放实体集,因此会设计到对list的各种操作,比较常见的有对list进行排序,查找,比较,去重复. ...

  3. Linq Enumerable.Distinct方法去重

    Enumerable.Distinct 方法 是常用的LINQ扩展方法,属于System.Linq的Enumerable方法,可用于去除数组.集合中的重复元素,还可以自定义去重的规则. 有两个重载方法 ...

  4. 使用代理实现对C# list distinct操作

    范型在c#编程中经常使用,而经常用list 去存放实体集,因此会设计到对list的各种操作,比较常见的有对list进行排序,查找,比较,去重复.而一般的如果要对list去重复如果使用linq dist ...

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

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

  6. C# Distinct使用,支持对象的相等比较

    官网Enumerable.Distinct https://msdn.microsoft.com/zh-cn/library/bb338049.aspx CSDN中作者oriency755 关于Dis ...

  7. lambda distinct

    public ActionResult Index() { IList<RegisterModel> regList = new List<RegisterModel>() { ...

  8. List<T>.Distinct()

    )            }; //使用匿名方法            List<Person> delegateList = personList.Distinct(new Compar ...

  9. DISTINCT 方法用于返回唯一不同的值 。

    DISTINCT 方法用于返回唯一不同的值 . 例如: $Model->distinct(true)->field('name')->select(); 生成的SQL语句是: SEL ...

随机推荐

  1. web题

    @php绕过https://www.cnblogs.com/leixiao-/p/9786496.html @step1:F12 step2:抓包 @任何url  http://118.25.14.4 ...

  2. 【DSP开发】【Linux开发】IIC设备驱动程序

    IIC设备是一种通过IIC总线连接的设备,由于其简单性,被广泛引用于电子系统中.在现代电子系统中,有很多的IIC设备需要进行相互之间通信 IIC总线是由PHILIPS公司开发的两线式串行总线,用于连接 ...

  3. confluent部署:

    confluent介绍https://www.cnblogs.com/dadadechengzi/p/9506964.html kafka connect:https://www.cnblogs.co ...

  4. 双元素非递增(容斥)--Number Of Permutations Educational Codeforces Round 71 (Rated for Div. 2)

    题意:https://codeforc.es/contest/1207/problem/D n个元素,每个元素有a.b两个属性,问你n个元素的a序列和b序列有多少种排序方法使他们不同时非递减(不同时g ...

  5. MyISAM与InnoDB的索引差异

    数据库的索引分为主键索引(Primary Index)与普通索引(Secondary Index).InnoDB和MyISAM是怎么利用B+树来实现这两类索引的,又有什么差异呢?一.MyISAM的索引 ...

  6. shell脚本获取的参数

    $# 是传给脚本的参数个数 $0 是脚本本身的名字 $1 是传递给该shell脚本的第一个参数 $2 是传递给该shell脚本的第二个参数 $@ 是传给脚本的所有参数的列表

  7. 十大经典排序算法(Python,Java实现)

    参照:https://www.cnblogs.com/wuxinyan/p/8615127.html https://www.cnblogs.com/onepixel/articles/7674659 ...

  8. vue中v-if和v-for优先级

    v-for和v-if不应该一起使用,必要情况下应该替换成computed属性.原因:v-for比v-if优先,如果每一次都需要遍历整个数组,将会影响速度,尤其是当之需要渲染很小一部分的时候.   错误 ...

  9. python 高级函数

    高级函数 map 格式:map(func, lt) 说明:接受两个参数,一个函数和一个可迭代对象,返回一个生成器,将func依次作用于lt 示例: l = [1,2,3,4,5]​def double ...

  10. echarts属性的设置

    // 全图默认背景  // backgroundColor: ‘rgba(0,0,0,0)’, // 默认色板 color: ['#ff7f50','#87cefa','#da70d6','#32cd ...