LingQ 的Distinct使用方法

Posted on 2014-12-03 14:16  性感的心田  阅读(198)  评论(0编辑  收藏  举报

需要将对象继承 IEqualityComparer<对象类名> 接口

然后实现下面两个方法 

public bool Equals(对象 x, 对象y)
{
return x.ID == y.ID;//比较是否重复的属性
}

public int GetHashCode(VideoInfo obj)
{
return obj.ToString().GetHashCode();
}

 使用:

结果集.Distinct(new 对象() );