Click here to Skip to main content
11,414,234 members (73,096 online)

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: What is null equal to? Pin
Rob Grainger, 29-Sep-14 0:20
memberRob Grainger29-Sep-14 0:20 
GeneralRe: What is null equal to? Pin
Paulo Zemek, 25-Aug-14 9:49
professionalPaulo Zemek25-Aug-14 9:49 
GeneralRe: What is null equal to? Pin
V., 25-Aug-14 20:43
professionalV.25-Aug-14 20:43 
JokeRe: What is null equal to? Pin
Vark111, 26-Aug-14 9:23
memberVark11126-Aug-14 9:23 
GeneralRe: What is null equal to? Pin
sloosecannon, 27-Aug-14 4:40
membersloosecannon27-Aug-14 4:40 
GeneralRe: What is null equal to? Pin
Eddy Vluggen, 27-Aug-14 8:33
professionalEddy Vluggen27-Aug-14 8:33 
GeneralRe: What is null equal to? Pin
sloosecannon, 27-Aug-14 8:41
membersloosecannon27-Aug-14 8:41 
GeneralRe: What is null equal to? Pin
Richard Deeming, 27-Aug-14 8:53
professionalRichard Deeming27-Aug-14 8:53 
Taking the code from Vark111's post, and assuming C#:
if (null == value || (null).Equals(value)) {
If value isn't null, the second part will be evaluated. Since the second part tries to call the Equals method on a null reference, it would throw a NullReferenceException. D'Oh! | :doh:

Thankfully, the C# compiler is smart enough to prevent you from compiling this code - you'll get an "Operator '.' cannot be applied to operand of type '<null>'" compiler error.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: What is null equal to? Pin
jeron1, 26-Aug-14 13:03
memberjeron126-Aug-14 13:03 
GeneralRe: What is null equal to? Pin
sloosecannon, 27-Aug-14 4:36
membersloosecannon27-Aug-14 4:36 
GeneralRe: What is null equal to? Pin
Rob Grainger, 27-Aug-14 6:49
memberRob Grainger27-Aug-14 6:49 
GeneralRe: What is null equal to? Pin
ColborneGreg, 31-Aug-14 8:39
memberColborneGreg31-Aug-14 8:39 
GeneralRe: What is null equal to? Pin
sankarsan parida, 4-Sep-14 1:22
professionalsankarsan parida4-Sep-14 1:22 
GeneralRe: What is null equal to? Pin
Munchies_Matt, 10-Sep-14 13:59
memberMunchies_Matt10-Sep-14 13:59 
GeneralGive a right username and a right password and you're in... Pin
yiangos, 25-Aug-14 5:38
professionalyiangos25-Aug-14 5:38 
GeneralRe: Give a right username and a right password and you're in... Pin
tgrt, 25-Aug-14 5:42
membertgrt25-Aug-14 5:42 
GeneralRe: Give a right username and a right password and you're in... [modified] Pin
PIEBALDconsult, 25-Aug-14 5:47
memberPIEBALDconsult25-Aug-14 5:47 
GeneralRe: Give a right username and a right password and you're in... Pin
BobJanova, 1-Sep-14 2:48
memberBobJanova1-Sep-14 2:48 
GeneralRe: Give a right username and a right password and you're in... Pin
JMK-NI, 25-Aug-14 5:53
memberJMK-NI25-Aug-14 5:53 
GeneralRe: Give a right username and a right password and you're in... Pin
Ian Shlasko, 25-Aug-14 5:55
professionalIan Shlasko25-Aug-14 5:55 
GeneralRe: Give a right username and a right password and you're in... Pin
yiangos, 25-Aug-14 6:41
professionalyiangos25-Aug-14 6:41 
GeneralRe: Give a right username and a right password and you're in... Pin
dexterama, 25-Aug-14 6:06
memberdexterama25-Aug-14 6:06 
GeneralRe: Give a right username and a right password and you're in... Pin
yiangos, 25-Aug-14 6:50
professionalyiangos25-Aug-14 6:50 
GeneralRe: Give a right username and a right password and you're in... Pin
PIEBALDconsult, 25-Aug-14 6:56
memberPIEBALDconsult25-Aug-14 6:56 
GeneralRe: Give a right username and a right password and you're in... Pin
yiangos, 25-Aug-14 7:05
professionalyiangos25-Aug-14 7:05 

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
Web01 | 2.8.150427.2 | Last Updated 27 Apr 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid