distinct a list of class objects by one attribute
class ItemEqualityComparer : IEqualityComparer<Class>
{
public bool Equals(Class x, Class y)
{
// Two items are equal if their keys are equal.
return x.Attribute == y.Attribute;
}
public int GetHashCode(Class obj)
{
return obj.Attribute.GetHashCode();
}
}
// then select distinct in method
List<Class> returnList = new List<Class>();
returnList = sourceList.Distinct(new ItemEqualityComparer()).ToList();