Click here to Skip to main content
15,891,704 members
Home / Discussions / C#
   

C#

 
QuestionDomain Pin
Michael O.6-Jun-07 2:09
Michael O.6-Jun-07 2:09 
NewsRe: Domain Pin
I Believe In GOD6-Jun-07 2:24
I Believe In GOD6-Jun-07 2:24 
QuestionCreating blinking I-Beam Pin
Vertyg06-Jun-07 2:02
Vertyg06-Jun-07 2:02 
AnswerRe: Creating blinking I-Beam Pin
I Believe In GOD6-Jun-07 2:16
I Believe In GOD6-Jun-07 2:16 
GeneralRe: Creating blinking I-Beam Pin
Vertyg06-Jun-07 2:20
Vertyg06-Jun-07 2:20 
GeneralRe: Creating blinking I-Beam Pin
leppie6-Jun-07 3:30
leppie6-Jun-07 3:30 
QuestionAre theses the same: object.Equal(obj,null) and obj == null? Pin
Christopher Stratmann6-Jun-07 1:31
Christopher Stratmann6-Jun-07 1:31 
AnswerRe: Are theses the same: object.Equal(obj,null) and obj == null? Pin
Guffa6-Jun-07 1:54
Guffa6-Jun-07 1:54 
chris175 wrote:
Is one better than the other?


The better one is the one that does exactly what you want to do...

if I have a ClassA that overloads the '==' operator then using ClassA == null will actually go into that overload operator function, but object.Equal(ClassA,null) does not go into the overloaded '==' operator function.


You are not talking about overloading, but overriding. Overloading is when you have more than one method with the same name but with different parameters.

Both the == operator and the Equals method can be overridden, and using either on the object will use the overridden one. If you override the == operator, you should also override the Equals method (and also the != operator and the GetHashCode method).

If you use Object.Equals, you have specified that it should use the static method in the Object class. Static methods can not be overridden.

Furthermore, what is really weird is if I say ClassA myClassA; in my code and do not set it. myClassA equals null


Only if you declare the variable in a class. If you declare it as a local variable in a method, it will be undefined, and the compiler will prevent you from using it before assigning it a value.

and then coding if (myClassA == null);. My overloaded '==' operator function will get called and I HAVE to use object.Equal(myClassA,null).


No, you don't HAVE to. You can simply cast your object to Object:

if ((object)myClassA == null)

This will use the == operator of the Object class instead of the overridden == operator.

---
single minded; short sighted; long gone;

GeneralRe: Are theses the same: object.Equal(obj,null) and obj == null? Pin
S. Senthil Kumar6-Jun-07 4:48
S. Senthil Kumar6-Jun-07 4:48 
GeneralRe: Are theses the same: object.Equal(obj,null) and obj == null? Pin
Guffa6-Jun-07 21:56
Guffa6-Jun-07 21:56 
QuestionBinding DataReader to DataGrid Pin
S Palip6-Jun-07 1:16
S Palip6-Jun-07 1:16 
AnswerRe: Binding DataReader to DataGrid Pin
Harini N K6-Jun-07 2:14
Harini N K6-Jun-07 2:14 
GeneralRe: Binding DataReader to DataGrid Pin
S Palip6-Jun-07 16:07
S Palip6-Jun-07 16:07 
QuestionPrint PDF via AcrobatReader and close it afterwards Pin
blackjack21506-Jun-07 1:11
blackjack21506-Jun-07 1:11 
AnswerRe: Print PDF via AcrobatReader and close it afterwards Pin
Seishin#6-Jun-07 1:50
Seishin#6-Jun-07 1:50 
GeneralRe: Print PDF via AcrobatReader and close it afterwards Pin
ScottM16-Jun-07 2:01
ScottM16-Jun-07 2:01 
GeneralRe: Print PDF via AcrobatReader and close it afterwards Pin
Seishin#6-Jun-07 2:12
Seishin#6-Jun-07 2:12 
GeneralRe: Print PDF via AcrobatReader and close it afterwards Pin
blackjack21506-Jun-07 2:01
blackjack21506-Jun-07 2:01 
GeneralRe: Print PDF via AcrobatReader and close it afterwards Pin
ScottM16-Jun-07 2:19
ScottM16-Jun-07 2:19 
GeneralRe: Print PDF via AcrobatReader and close it afterwards Pin
jethomas414-Oct-09 6:07
jethomas414-Oct-09 6:07 
GeneralRe: Print PDF via AcrobatReader and close it afterwards Pin
blackjack215015-Oct-09 1:08
blackjack215015-Oct-09 1:08 
QuestionRe: Print PDF via AcrobatReader and close it afterwards Pin
M. J. Jaya Chitra7-Jun-07 18:12
M. J. Jaya Chitra7-Jun-07 18:12 
Questionwant to change the property of column header in datagridview Pin
devesh_code6-Jun-07 0:17
devesh_code6-Jun-07 0:17 
AnswerRe: want to change the property of column header in datagridview Pin
Praveen Raghuvanshi6-Jun-07 0:43
professionalPraveen Raghuvanshi6-Jun-07 0:43 
GeneralRe: want to change the property of column header in datagridview Pin
devesh_code6-Jun-07 2:38
devesh_code6-Jun-07 2:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.