1.调用:

UserList = UserList.ToList().Intersect(userIDList, new MyUserComparer()).AsQueryable();

2.须要重写的方法:

public class MyUserComparer : IEqualityComparer<MyUser>
{
public bool Equals(MyUser x, MyUser y)
{
//throw new NotImplementedException();
return x.UserID == y.UserID;
}
public int GetHashCode(MyUser obj)
{
return obj.ToString().GetHashCode();
}
}

LINQ获取两个List的交集的更多相关文章

  1. C# Linq获取两个List或数组的差集交集

      List<); list1.Add(); list1.Add(); List<); list2.Add(); list2.Add(); //得到的结果是4,5 即减去了相同的元素. L ...

  2. js 获取两个数组的交集,并集,补集,差集

    https://blog.csdn.net/piaojiancong/article/details/98199541 ES5 const arr1 = [1,2,3,4,5], arr2 = [5, ...

  3. C# Linq 取得两个列表的交集

    我们经常会用到linq 来查询 一个数组中和另一个数组中相同的项, 这个时候就会用到IEqualityComparer接口. public class StudyInfoModel {      pu ...

  4. Python获取两个文件的交集、并集、差集

    题记:朋友在处理数据时,需要解决这方面的问题,所以利用她给的代码,自己重新梳理了下,并成功运行. 代码如下: # coding:utf-8 s1 = set(open(r'C:\\Users\\yan ...

  5. python两个 list 交集,并集,差集的方法+两个tuple比较操作+两个set的交集,并集,差集操作+两个dict的比较操作

    转自:http://blog.chinaunix.net/uid-200142-id-3992553.html 有时候,为了需求,需要统计两个 list 之间的交集,并集,差集.查询了一些资料,现在总 ...

  6. SQL Server中取两个表的交集,并集和差集

    在项目中遇到要取两个表差集的情况 假设有两个表tblNZPostCodes, NZPostcode  两个表中存储的都是新西兰的post code信息,字段一致,只是数据上有所差异. 1. Union ...

  7. php获取两个数组相同的元素(交集)以及比较两个数组中不同的元素(差集)

    (一)php获取两个数组相同元素 array  array_intersect(array  $array1, array $array2, [, array $...]) array  array_ ...

  8. 求两个集合的交集和并集C#

    我是用hashset<T>来实现的 具体如代码所示 using System; using System.Collections.Generic; using System.Linq; u ...

  9. javascript 常见数组操作( 1、数组整体元素修改 2、 数组筛选 3、jquery 元素转数组 4、获取两个数组中相同部分或者不同部分 5、数组去重并倒序排序 6、数组排序 7、数组截取slice 8、数组插入、删除splice(需明确位置) 9、数组遍历 10、jQuery根据元素值删除数组元素的方)

    主要内容: 1.数组整体元素修改 2. 数组筛选 3.jquery 元素转数组 4.获取两个数组中相同部分或者不同部分 5.数组去重并倒序排序 6.数组排序 7.数组截取slice 8.数组插入.删除 ...

随机推荐

  1. 多校4 lazy running (最短路)

    lazy running(最短路) 题意: 一个环上有四个点,从点2出发回到起点,走过的距离不小于K的最短距离是多少 \(K <= 10^{18} 1 <= d <= 30000\) ...

  2. 【POJ 3080 Blue Jeans】

    Time Limit: 1000MSMemory Limit: 65536K Total Submissions: 19026Accepted: 8466 Description The Genogr ...

  3. Python之多线程:Threading模块

    1.Threading模块提供的类 Thread,Lock,Rlock,Condition,Semaphore,Event,Timer,local 2.threading模块提供的常用的方法 (1)t ...

  4. git项目初始化的问题汇总

    转:https://blog.csdn.net/Free_Wind22/article/details/81628721 1.在Git官网上点击New repository新建项目: 2.在本地新建一 ...

  5. c++ 操作防火墙

    原文转自 https://msdn.microsoft.com/zh-cn/library/aa364726(v=vs.85).aspx #include <windows.h> #inc ...

  6. MFC/C++/C中字符类型CString, int, string, char*之间的转换

    1 CString,int,string,char*之间的转换 string 转 CString CString.format("%s", string.c_str()); cha ...

  7. 华为上机测试题(大数相乘-java)

    PS:这个不是自己写的,测试OK,供参考. /** * 大数相乘 */ public class BigData { public static void main(String[] args) { ...

  8. git使用过程中遇到的错误

    1.使用git add "login.py" 然后git commit -m "add url"的时候报错.分支newtype也是存在的 nothing to ...

  9. python 拼图验证码

    基于python2.7 django 1.10 用谷歌浏览器验证测试没问题,写的很烂,纯属学习 项目地址 https://github.com/cainiaoit/-Jigsaw-verifying- ...

  10. Kubernetes监控工具

    #镜像在谷歌上需要FQ#####################################监控工具#当前最新版本 heapster https://github.com/kubernetes/h ...