Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Why string overloads == operator ?

$
0
0

Hi All,

I knew that strings are reference type and overloads == operator.

string s1 = "xyz";

string s2 = "xyz";

if (s1 == s2) ======> gives the TRUE

if (String.ReferenceEquls(s1,s2)) =========> gives false

since strings are reference type both holds difference reference values and as i know strings overloads == operator. 

I have surfed internet but dint get exact answer why does string overloads == and why do they behave like value type ?




Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>