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, 1895👍, 0💬
Popular Posts:
How To Avoid the Undefined Index Error? - PHP Script Tips - Processing Web Forms If you don't want y...
How was XML handled during COM times? During COM it was done by using MSXML 4.0. So old languages li...
Write down the equivalent pointer expression for referring the same element a[i][j][k][l]? a[i] == *...
Can you explain in brief how the ASP.NET authentication process works? ASP.NET does not run by itsel...
Can you tell me how to check whether a linked list is circular? Create two pointers, and set both to...