A strange piece of code I\'ve just discovered in C# (should also be true for other CLI languages using .NET\'s structs).
They are not the same because even simple types are inherited from System.Object - they are actually objects, and different object types, even with the same property values are not equal.
Example:
You could have a Co-Worker object with only one property: Name (string) and a partner object with only one property: Name (string)
Co-worker David is not the same as Parner David. The fact that they are different object types sets them apart.
In your case, using .Equals(), you're not comparing values, you're comparing objects. The object isn't "0" it's a System.Int32 with a Value of zero, and a System.Int64 with a value of zero.
Code sample based on question in comment below:
class CoWorker
{
public string Name { get; set; }
}
class Partner
{
public string Name { get; set; }
}
private void button1_Click(object sender, RoutedEventArgs e)
{
CoWorker cw = new CoWorker();
cw.Name = "David Stratton";
Partner p = new Partner();
p.Name = "David Stratton";
label1.Content = cw.Equals(p).ToString(); // sets the Content to "false"
}