I have an class like this:
public class Inner {
public int foo;
public int bar;
}
and an outer class:
public class Outer {
public string Name;
public IEnumerable<Inner> foobars;
}
When I compare two objects, I do this:
// I have to instances of Outer, called A and B
if (A.Equals(B)) {
// do something
}
I know I need to implement the IEquatable interface or possibly IEqualityComparer (or both), and while this seems simple enough, I have yet to see how to implement it in this situation where Outer has en IEnumerable of Inner objects.
Do I have to implement IEquatable/IEqualityComparer on both Inner and Outer? And how do I make sure the lists are compared properly and not just by reference?
I have searched a lot on stackoverflow and google in general but have missed the proper solution.