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, 2121👍, 0💬
Popular Posts:
How To Use Subqueries with the IN Operator? - MySQL FAQs - SQL SELECT Statements with JOIN and Subqu...
Jack developed a program by using a Map container to hold key/value pairs. He wanted to make a chang...
How can I implement a thread-safe JSP page? You can make your JSPs thread-safe by having them implem...
Why is there extra white space before or after tables? This is often caused by invalid HTML syntax. ...
How Many Tags Are Defined in HTML 4.01? There are 77 tags defined in HTML 4.01: a abbr acronym addre...