Click here to Skip to main content
15,885,874 members
Home / Discussions / C#
   

C#

 
QuestionBest Practices: Checking For Null Objects After Initializing Pin
Wainwrightwt21-May-10 3:24
Wainwrightwt21-May-10 3:24 
AnswerRe: Best Practices: Checking For Null Objects After Initializing Pin
PIEBALDconsult21-May-10 3:35
mvePIEBALDconsult21-May-10 3:35 
AnswerRe: Best Practices: Checking For Null Objects After Initializing Pin
harold aptroot21-May-10 3:36
harold aptroot21-May-10 3:36 
AnswerRe: Best Practices: Checking For Null Objects After Initializing Pin
Luc Pattyn21-May-10 3:44
sitebuilderLuc Pattyn21-May-10 3:44 
GeneralRe: Best Practices: Checking For Null Objects After Initializing Pin
PIEBALDconsult21-May-10 3:52
mvePIEBALDconsult21-May-10 3:52 
GeneralRe: Best Practices: Checking For Null Objects After Initializing Pin
Md. Marufuzzaman21-May-10 4:53
professionalMd. Marufuzzaman21-May-10 4:53 
GeneralRe: Best Practices: Checking For Null Objects After Initializing Pin
Md. Marufuzzaman21-May-10 4:55
professionalMd. Marufuzzaman21-May-10 4:55 
AnswerRe: Best Practices: Checking For Null Objects After Initializing Pin
Covean21-May-10 3:51
Covean21-May-10 3:51 
The reason for that is maybe he is an old c++ developer.
IN C++ the new and all other allocation functions could
return a null pointer if the function couldn't allocate
the memory.

In C# this is not necessary, because it allocates the memory
block you requested or it throws an OutOfMemoryException.


But it is a common mistake made by the most old c++
developer (including me Poke tongue | ;-P ) as they started
developing in C#.

Edit:
But throwing a NullReferenceException is very uncommon and cruel (can be misunderstood).
Greetings
Covean

GeneralRe: Best Practices: Checking For Null Objects After Initializing Pin
Wainwrightwt21-May-10 4:16
Wainwrightwt21-May-10 4:16 
GeneralRe: Best Practices: Checking For Null Objects After Initializing Pin
Covean21-May-10 4:27
Covean21-May-10 4:27 
GeneralRe: Best Practices: Checking For Null Objects After Initializing Pin
Luc Pattyn21-May-10 4:42
sitebuilderLuc Pattyn21-May-10 4:42 
GeneralRe: Best Practices: Checking For Null Objects After Initializing Pin
Wainwrightwt21-May-10 5:22
Wainwrightwt21-May-10 5:22 
QuestionMultiple forms in C# Pin
Etienne_12321-May-10 2:26
Etienne_12321-May-10 2:26 
AnswerRe: Multiple forms in C# Pin
#realJSOP21-May-10 2:30
mve#realJSOP21-May-10 2:30 
AnswerRe: Multiple forms in C# Pin
Luc Pattyn21-May-10 3:45
sitebuilderLuc Pattyn21-May-10 3:45 
AnswerRe: Multiple forms in C# Pin
PIEBALDconsult21-May-10 4:33
mvePIEBALDconsult21-May-10 4:33 
GeneralRe: Multiple forms in C# Pin
Luc Pattyn21-May-10 4:44
sitebuilderLuc Pattyn21-May-10 4:44 
AnswerRe: Multiple forms in C# Pin
Henry Minute21-May-10 6:16
Henry Minute21-May-10 6:16 
AnswerRe: Multiple forms in C# Pin
William Winner21-May-10 7:44
William Winner21-May-10 7:44 
Questionstring.format Pin
tek 200921-May-10 1:21
tek 200921-May-10 1:21 
AnswerRe: string.format Pin
J4amieC21-May-10 1:27
J4amieC21-May-10 1:27 
GeneralRe: string.format Pin
tek 200921-May-10 1:47
tek 200921-May-10 1:47 
GeneralRe: string.format Pin
The Man from U.N.C.L.E.21-May-10 2:16
The Man from U.N.C.L.E.21-May-10 2:16 
AnswerRe: string.format Pin
#realJSOP21-May-10 2:00
mve#realJSOP21-May-10 2:00 
AnswerRe: string.format Pin
#realJSOP21-May-10 2:03
mve#realJSOP21-May-10 2:03 

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.