Q:

Reflexive objects in c#, 10 not 10?

I am testing reflexibe object to make a method to obtain the changes betwen two object whitout know the class and i got this:

name, apellido and otromas are strings.
edad its a int.

A:

It's best to use object.Equals(value1, value2) in this cenario.
The == sign actually executes object.ReferenceEquals and checks if the memory addresses of both objects are the same instead of the actual values.
var value1 = (object)1;
var value2 = (object)1;

Console.WriteLine(value1 == value2);                        // False
Console.WriteLine(object.ReferenceEquals(value1, value2));  // False
Console.WriteLine(value1.Equals(value2));                   // True
Console.WriteLine(object.Equals(value1, value2));           // True

And its better to use object.Equals instead of value1.Equals, because the following example changing value1 to null will cause an exception to be thrown
var value1 = (object)null;
var value2 = (object)1;

Console.WriteLine(value1 == value2);                       // False
Console.WriteLine(object.ReferenceEquals(value1, value2)); // False
Console.WriteLine(value1.Equals(value2));                  // NullReferenceException
Console.WriteLine(object.Equals(value1, value2));          // False

