ASP.Net Interview Questions and Answers
<< Previous Question Next Question >>
 Question: 555 Page Views: 

Is there any difference between a==b and a.Equals(b)?



Posted By: Avi Date: 30 September 2010 10:31:14 PM
 Answer:

Both are used for comparisons but it depends whether they are being compared value based or refrence based. Value Based:- For the type "==" and "Equals" works exactly the same such as will compare the values and will return true if a nd b have equal values in them. Example:- int a = 1; int b= 1; a == b >> True a.Equals(b) >> True Refrence Based:- In this case "==" compares the refrence and returns true if and only if both refrence points are same. But "Equal" still compares the value at that refrence points.. So if values are same the result will be true else false. Example:- StringBuilder a = new StringBuilder(“Hello”); StringBuilder b = new StringBuilder(“Hello”); a == b >> False a.Equals(b) >> True But now look at following issue: String a = “Hello”; String b = “Hello”; In above case the results will be, a == b >> True a.Equals(b) >> True


Posted By: avibtech


Date: 30 September 2010 10:31:14 PM
Post a better Answer if you have
 
(Will show your Gravatar icon)  
  Country flag

Loading
Enter the text as shown in the image R0S9mn
Related Questions
ASP.Net : There are two common properties in every validation control. What are they?

There are two common properties in every validation control. What are they?

They are:- ControlToValidate property and Text property.
Category: ASP.Net Date: 9/30/2010 4:29:13 PM
ASP.Net : Name the vent in which the controls are fully loaded?

Name the vent in which the controls are fully loaded?

It is the Page load event which Gurantees that all the controls are fully loaded.
Category: ASP.Net Date: 9/30/2010 4:15:14 PM
ASP.Net : How can we Restart an Application Pool?

How can we Restart an Application Pool?

We can restart a specific Application Pool by using the IIS Manager GUI or using cscript.exe in the ....
Category: ASP.Net Date: 1/3/2010 11:39:12 AM
ASP.Net : Explain various Validation Controls available in ASP.Net?

Explain various Validation Controls available in ASP.Net?

There are five types of Validation Controls available in ASP.Net: 1) RequiredField Validation contr....
Category: ASP.Net Date: 11/30/2009 3:28:15 PM
ASP.Net : How to set default button on a ASP.Net Web Form?

How to set default button on a ASP.Net Web Form?

In ASP.Net 2.0, we can set a default button on a page so that when the user presses the Enter key th....
Category: ASP.Net Date: 11/30/2009 5:01:16 AM