Wednesday, December 14, 2011

Best way to compare two objects in C#



Compare 2 instances of the class SubComponent


public class SubComponentSequenceComparer : IEqualityComparer
{
public bool Equals(SubComponent x, SubComponent y)
{
return x.Sequence == y.Sequence;
}

public int GetHashCode(SubComponent obj)
{
return obj.Sequence.GetHashCode();
}
}

No comments:

Post a Comment