Jatin Kumar

Jatin Kumar

  • NA
  • 1
  • 0

doubt in c# basic

Jun 17 2009 9:07 AM
class s
{
static void Main()
{
string d="Hello";
string e=string.Copy(d);
Console.WriteLine(d==e);
Console.WriteLine((object)d==(object)e);
}
}
o/p:
True
False

BUT

class s
{
static void Main()
{
object a = "hello";
object b = "hello";
Console.WriteLine(a==b);
}
}
o/p:
True.

In the previous case when the result of the comparison is false, we compare two strings and as string is a predefined reference type...so d result should evaluate to true and not false.

Please clear my doubt.




Answers (1)