Click here to Skip to main content

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrasing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: No foreign keys on the first date. Pinmemberryan_b200917-Dec-12 7:55 
GeneralRe: No foreign keys on the first date. PinmemberBrady Kelly17-Dec-12 8:04 
GeneralHow do you like your nulls PinmemberRobert Hoffmann8-Dec-12 2:57 
GeneralRe: How do you like your nulls PinmemberZac Greve8-Dec-12 8:25 
GeneralRe: How do you like your nulls Pinmemberlewax008-Dec-12 16:32 
GeneralRe: How do you like your nulls PinmemberZac Greve8-Dec-12 17:23 
GeneralRe: How do you like your nulls Pinmemberlewax008-Dec-12 17:33 
AnswerRe: How do you like your nulls PinmemberRobert Hoffmann9-Dec-12 0:55 
I understand your logic, but User can be null.
 
But either way turned ToString in this situation is also completely redundant because IsNullOrEmpty already does 2 specific checks. Is the item null, or is the item an empty string.
 
So the correct code, without triggering a NullReferenceException should have been
if (!string.IsNullOrEmpty(User)) {
 
}
 
Thumbs Up | :thumbsup:
GeneralRe: How do you like your nulls Pinmemberlewax009-Dec-12 1:35 
GeneralRe: How do you like your nulls PinmemberRobert Hoffmann9-Dec-12 10:39 
GeneralRe: How do you like your nulls Pinmemberpatbob10-Dec-12 6:32 
GeneralRe: How do you like your nulls PinmemberTomz_KV10-Dec-12 3:28 
GeneralRe: How do you like your nulls PinmemberZac Greve10-Dec-12 10:17 
GeneralRe: How do you like your nulls PinmemberEddy Vluggen10-Dec-12 15:26 
GeneralRe: How do you like your nulls PinmemberBobJanova9-Dec-12 23:49 
GeneralRe: How do you like your nulls PinmemberRafagaX10-Dec-12 6:28 
GeneralRe: How do you like your nulls Pinmemberjibesh12-Dec-12 23:35 
GeneralRe: How do you like your nulls PinmemberRafagaX13-Dec-12 5:30 
GeneralRe: How do you like your nulls PinprotectorAspDotNetDev10-Dec-12 7:35 
JokeRe: How do you like your nulls PinmemberZac Greve10-Dec-12 10:18 
GeneralRe: How do you like your nulls PinmemberFlorin Jurcovici11-Dec-12 11:18 
GeneralCount the horrors PinmemberJörgen Andersson6-Dec-12 23:37 
GeneralRe: Count the horrors PinmvpOriginalGriff8-Dec-12 5:38 
GeneralQ: What is the sound of one value coalescing? PinmemberPIEBALDconsult6-Dec-12 9:04 
General42 PinprotectorAspDotNetDev5-Dec-12 14:45 

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

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


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 20 Dec 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid