zoukankan      html  css  js  c++  java
  • LINQ获取两个List的交集

    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();
    }
    }

    ---------------------
    作者:FreeBeer2015
    来源:CSDN
    原文:https://blog.csdn.net/anpan1045535101/article/details/40588017
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    Properties类
    缓冲流
    Mybatis
    分页查询
    QueryRunner和JDBC连接池
    JSP
    Session
    Cookie
    http协议和eclipes绑定tomcat
    servlet
  • 原文地址:https://www.cnblogs.com/suizhikuo/p/11084331.html
Copyright © 2011-2022 走看看