Tag Archives: IEquatable

Determine whether two lists contain the same sequences of objects in different orders in C#

The SequenceEqual method determines whether two IEnumerable sequences contain the same objects in the same order. There is a simple way to determine whether the lists contain the same objects in different orders: sort the objects and then call SequenceEqual. … Continue reading

Posted in LINQ, lists, miscellany, OOP | Tagged , , , , , , , , , , , , , | Leave a comment

Determine whether two lists contain the same sequences of objects in C#

The IEnumerable interface provides a SequenceEqual method that determines whether two IEnumerable sequences contain the same objects. Normally, it uses reference equality so it considers two objects equal only if they refer to the same instance. However, if the objects … Continue reading

Posted in lists, miscellany, OOP | Tagged , , , , , , , , , , , | 2 Comments

Make a list without duplicates in C#

This example builds a list of Person objects without duplicates. The following code shows the Person class. public class Person : IEquatable<Person> { public string FirstName, LastName; public Person(string first_name, string last_name) { FirstName = first_name; LastName = last_name; } … Continue reading

Posted in generic, lists | Tagged , , , , , , , , , , , | Leave a comment