Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
What is the difference between a.Equals(b) and a == b?
What is the difference between a.Equals(b) and a == b?
✍: Guest
Answer1:
a=b is used for assigning the values (rather then comparison) and a==b is for comparison.
Answer2:
a == b is used to compare the references of two objects
a.Equals(b) is used to compare two objects
Answer3:
A equals b -> copies contents of b to a
a == b -> checks if a is equal to b
Answer4:
Equals method compares both type and value of the variable, while == compares value.
int a = 0;
bool b = 0
if(a.Equals(b))
Answer5:
a.Equals(b) checks whether the Type of a is equal to b or not! Put it in another way,
Dim a As Integer = 1
Dim b As Single = 1
a.Equals(b) returns false. The Equals method returns a boolean value.
a == b is a simple assignment statement.
Answer6:
a.equals(b) will check whether the “b†has same type as “a†has and also has the same data as “a†has.
a==b will do the same thing.
if you have done this in c++ under “operator overloading†than you guys must be aware of this sytaxts. they are doing the same thing there is only sytaxtical difference.
let me explain it in different manner.
a==b : means compare “b†with “aâ€. always left hand side expression evaluated first so here in this case “a†(considered an object) will call the overloaded operator “=†which defines “Equals(object)†method in it’s class. thus, ultimately a.equals(b) goanna called.
so the answer is: both will perform the same task. they are different by syntaxt
Answer7:
Difference b/w a==b,a.Equals(b)
a.Equals(b):
The default implementation of Equals supports reference equality only, but derived classes can override this method to support value equality.
For reference types, equality is defined as object equality; that is, whether the references refer to the same object. For value types, equality is defined as bitwise equality
== :
For predefined value types, the equality operator (==) returns true if the values of its operands are equal, false otherwise. For reference types other than string, == returns true if its two operands refer to the same object. For the string type, == compares the values of the strings.
2014-02-26, 1839👍, 0💬
Popular Posts:
Should synchronization primitives be used on overrided bean methods? No. The EJB specification speci...
What is continuous and staged representation? CMMI contains 25 key process areas which organization ...
Where Is the Submitted Form Data Stored? - PHP Script Tips - Processing Web Forms When a user submit...
How To Delete All Rows a Table? - MySQL FAQs - Understanding SQL INSERT, UPDATE and DELETE Statement...
How to make elements invisible? Change the "visibility" attribute of the style object associated wit...