Categorized | C# FAQ

Difference between == and Object.Equals Method in C#

protected void Page_Load(object sender, EventArgs e)

{

object s1 = “abc”;

object s2 = “abc”;

if (s1 == s2)

{

Response.Write(“value of s1 and s2 are equal”);

}

else if(s1.Equals(s2))

{

Response.Write(“Address of s1 and s2 are equal”);

}

/***************************************************************

* 1.==compares values of the variables.

* 2.Object.Eqals Method compares address of the variables

* **************************************************************/    }

Author: Raghavendra

Click here for job guarantee courses in bangalore

EasyFreeAds Blog News Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google Yahoo Buzz StumbleUpon

Leave a Reply