-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: rags_rao
Message 7 in Discussion
>Equals is a method provided by the string class for comparison between strings
agreed. actaully overrides object.Equals >whereas == is an operator for comparing any
of the objects not exactly.... string class implements == object overload (java can
never do this. thats the diff). but otherwise == checks if 2 references refer to same
object or not dont believe me? here the proof (code speaks louder than words): using
System; public class StrTest
{
static void Main()
{
string a = new string(new char[] {'a', 'e', 'i', 'o', 'u'});
string b = new string(new char[] {'a', 'e', 'i', 'o', 'u'});
//a,b point to 2 diff objects Console.WriteLine
(a==b);//string class implements ==
Console.WriteLine (a.Equals(b));//it overides Equals
Console.WriteLine (object.ReferenceEquals(a,b));//see? they r diff objs indeed
object c = a;
object d = b; Console.WriteLine (c==d);//FALSE: object has no
defnition for == and c,d r diff objects
Console.WriteLine (c.Equals(d));
//runtime polymorphism @ work string.Equals is called
//(since Equlas is virtual fn), not object.Equals string
x="aeiou",y="aeiou";
//x,y point to same object.remember immutable r strings?
Console.WriteLine (object.ReferenceEquals(x,y));//thats the proof
c=x;d=y;
Console.WriteLine (c==d);//some more proof
Console.WriteLine (c.Equals(d));//again string.Equals is called
}
}
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/BDOTNET/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]