class A
{
public int i;
public A()
{
i = 10;
}
}
class Program
{
static void Main(string[] args)
{
A a = new A(); // creating class object
A b = new A();// creating class object
if (a.Equals(b)) // checking whether they are equal not by ==
{
Console.WriteLine("Both objects are equal ");
}
else
{
Console.WriteLine("Both objects are not equal ");
}
Console.ReadLine();
}
// O/P : Both objects are not equal
}
}
I have declared two object of class A
. Both are initialized with data member value i = 10
in the constructor. But on comparing the objects, the output is "Both objects are not equal".
I would like to know why the objects are not equal.