View Single Post
Old 10-29-2006, 04:41 PM   #16 (permalink)
noobie
Forum Expert
 
Join Date: Jul 2005
Location: Istanbul/Turkey
Age: 27
Posts: 425
Default

C, I dont get the point with your code..

I dont have any compiler right now but try these ones:

string a="mystr";
string b="mystr";

Console.WriteLine(a==b); //true
Console.WriteLine(a.Equals(b)); //true


however then try this one:

int x=5;

Console.WriteLine((Object)x == (Object)x); //false
Console.WriteLine(x.Equals(x)); //true


and finally try this one:
Object x=5;
Object y=5;

Console.WriteLine(x==y); //false
Console.WriteLine(x.Equals(y)); //true


So string camparisons with == operator is different than others.

(I couldnt test it.Let me know if any results is not same with mine)
__________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."
noobie is offline   Reply With Quote