Given two instances of a class, is it a good and reliable practice to compare them by serializaing them first and then comparing byte arrays (or possibly hashes of arrays). These objects might have complex hierarchical properties but serialization should go as deep as required.
By comparison I mean the process of making sure that all propertis of primitive types have equal values, properties of complex types have equal properties of primitive types, etc. As for collection properties, they should be equal to each other: equal elements, same positions:
{'a','b','c'} != {'a','c','b'}
{new Customer{Id=2, Name="abc"}, new Customer {Id=3, Name="def"}}
!=
{new Customer{Id=3, Name="def"}, new Customer {Id=2, Name="abc"}}
but
{new Customer{Id=2, Name="abc"}, new Customer {Id=3, Name="def"}}
==
{new Customer{Id=2, Name="abc"}, new Customer {Id=3, Name="def"}}
And by serialization I mean standard .NET binary formatter.
Thanks.