linq去重方法
////// 用于Linq的去重,扩展方法需要放到静态类中 /// /// /// /// /// /// public static IEnumerable DistinctBy (this IEnumerable source, Func keySelector) { HashSet seenKeys = new HashSet (); foreach (TSource element in source) { if (seenKeys.Add(keySelector(element))) { yield return element; } } } 调用方法: list.DistinctBy(tmp => new { tmp.CountryName, tmp.VisaTypeName });