🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.csharpbuilder.language.csharp
Article #520

Re: about equal

#520
From: Barry Mossman
Date: Fri, 12 Nov 2004 02:51
27 lines
1596 bytes
"lobster" <superxr@21cn.com> wrote in message 
news:41941ac9@newsgroups.borland.com...
> hi,all, what's the difference between
> equals, referenceequals,==?
>
> like this:
> string a = "123";
> string b = "123";
> bool flag = ReferenceEquals(a,b);
> why the flag is true?

Will be compiler optimisation.

try:
   string a = "123";
   string b = "1";
   string c = "23";
   string d = b + c;
   bool flag = ReferenceEquals(a,d);
   Console.WriteLine(d);

   Console.WriteLine(flag);
   flag = Equals(a,d);
   Console.WriteLine(flag);
   Console.ReadLine();

Barry Mossman 
Technical Details
Message-ID: <4194254a@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news-hub.cableinet.net!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <41941ac9@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,4ce6d5ccdf90d708
X-Google-Attributes: gid1efe35,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Barry Mossman" <BMossmanNOSPAM@gmail.com>
Newsgroups: borland.public.csharpbuilder.language.csharp
References: <41941ac9@newsgroups.borland.com>
Subject: Re: about equal
Date: Fri, 12 Nov 2004 12:51:14 +1000
Lines: 29
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 144.134.27.139
Message-ID: <4194254a@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1100227914 144.134.27.139 (11 Nov 2004 18:51:54 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news-hub.cableinet.net!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail