static void Main(string[] args) { ObjectA a = new ObjectA() { FieldA = "test", FieldB = "test2", FieldC = "test3" }; ObjectB b = new ObjectB() { FieldA = "test", FieldB = "test2", FieldC = "test3" }; if (a.ComparePropertiesTo(b)) { Console.WriteLine("objects have the same properties"); } else { Console.WriteLine("objects have diferent properties!"); } Console.Read(); }
static void Main(string[] args) { // create two objects with same properties ObjectA a = new ObjectA() { PropertyA = "test", PropertyB = "test2", PropertyC = "test3" }; ObjectB b = new ObjectB() { PropertyA = "test", PropertyB = "test2", PropertyC = "test3" }; // add fields to those objects a.FieldA = "hello"; b.FieldA = "Something differnt"; if (a.ComparePropertiesTo(b)) { Console.WriteLine("objects have the same properties"); } else { Console.WriteLine("objects have diferent properties!"); } if (a.CompareFieldsTo(b)) { Console.WriteLine("objects have the same Fields"); } else { Console.WriteLine("objects have diferent Fields!"); } Console.Read(); }