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

3 comments:

  1. An iOS application development course explains mobile app architecture clearly. It supports practical learning through real-time projects. This ios application development course improves development skills. It is effective.

    ReplyDelete
  2. Well explained! We teach ui and ux design course
    using practical, user-focused design scenarios.

    ReplyDelete
  3. Salesforce Admin Training
    Thanks for putting together such useful content. I’ve also been looking into training options and found this salesforce admin training. Sharing it here.

    ReplyDelete