T
Tony Johansson
Hi!
In this example give the Equals(comparing references) method true because it
finds the string hello in the string pool. So when looking at s2 it find
that we already have a hello in the pool and the program is using that one.
thay have
Now to the second example using the ==. The statement give false but this is
really strange why does not the program find the hello in the string pool in
the second example
Can somebody explain what is happenin here ?
static void Main(string[] args)
{
String s1 = "hello";
String s2 = "hell";
s2 += "o";
bool b = ((object)s1).Equals((object)s2); //Evaluates to true
bool b2 = ((object)s1) == ((object)s2); //Evaluates to false
}
//Tony
//Tony
In this example give the Equals(comparing references) method true because it
finds the string hello in the string pool. So when looking at s2 it find
that we already have a hello in the pool and the program is using that one.
thay have
Now to the second example using the ==. The statement give false but this is
really strange why does not the program find the hello in the string pool in
the second example
Can somebody explain what is happenin here ?
static void Main(string[] args)
{
String s1 = "hello";
String s2 = "hell";
s2 += "o";
bool b = ((object)s1).Equals((object)s2); //Evaluates to true
bool b2 = ((object)s1) == ((object)s2); //Evaluates to false
}
//Tony
//Tony