Hi, i want to compare two objects. i wrote the program as bellow,
............... .........
namespace TestPrograms
{
class test
{
public int i;
}
class Exercise
{
public static void Main(string[] s)
{
test t1=new test();
test t2=new test();
t2.i=10;
t1.i=10;
if(t1.Equals(t2 ))
{
Console.WriteLi ne("Eql");
}
else
{
Console.WriteLi ne("NotEql");
}
}
}
}
............... .....
O/P is "NotEql"
............... ...
my question is ,
why t1 and t2 are not equal?
when two objects are said to be equal?
............... .........
namespace TestPrograms
{
class test
{
public int i;
}
class Exercise
{
public static void Main(string[] s)
{
test t1=new test();
test t2=new test();
t2.i=10;
t1.i=10;
if(t1.Equals(t2 ))
{
Console.WriteLi ne("Eql");
}
else
{
Console.WriteLi ne("NotEql");
}
}
}
}
............... .....
O/P is "NotEql"
............... ...
my question is ,
why t1 and t2 are not equal?
when two objects are said to be equal?
Comment