Click here to Skip to main content
15,903,012 members

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, embarrassing 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: Straight from the horse's mouth Pin
Rob Grainger17-Feb-12 3:43
Rob Grainger17-Feb-12 3:43 
GeneralRe: Straight from the horse's mouth Pin
mbb0117-Feb-12 22:32
mbb0117-Feb-12 22:32 
GeneralDo you want string or string? Pin
BotCar9-Feb-12 21:10
BotCar9-Feb-12 21:10 
GeneralRe: Do you want string or string? Pin
GibbleCH10-Feb-12 3:41
GibbleCH10-Feb-12 3:41 
JokeRe: Do you want string or string? Pin
Chris Meech10-Feb-12 6:33
Chris Meech10-Feb-12 6:33 
GeneralRe: Do you want string or string? Pin
fjdiewornncalwe10-Feb-12 8:12
professionalfjdiewornncalwe10-Feb-12 8:12 
GeneralRe: Do you want string or string? Pin
Julien Villers13-Feb-12 22:07
professionalJulien Villers13-Feb-12 22:07 
GeneralRe: Do you want string or string? Pin
Dan Neely10-Feb-12 12:47
Dan Neely10-Feb-12 12:47 
Refactoring Fail.

To match the original functionality what you need is String.IsNullOrWhiteSpace(). String.IsNullOrEmpty(lastItem.Value) will return false if lastItem.Value equals " ". String.IsNullOrEmpty(lastItem.Value.Trim()) will exception if lastItem.Value is null.

My other question would be how old the codebase is? IsNullOrEmpty() wasn't added until .net 2.0; IsNullOrWhiteSpace() wasn't added until 4.0.

I wrote an IsNullOrEmpty() method when I needed one in a 1.1 app; but unless you're doing it in multiple locations there's nothing wrong with inlining.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius


Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt

GeneralRe: Do you want string or string? Pin
V.12-Feb-12 23:38
professionalV.12-Feb-12 23:38 
GeneralRe: Do you want string or string? Pin
OriginalGriff13-Feb-12 0:37
mveOriginalGriff13-Feb-12 0:37 
GeneralRe: Do you want string or string? Pin
CDP180213-Feb-12 2:22
CDP180213-Feb-12 2:22 
GeneralRe: Do you want string or string? Pin
OriginalGriff13-Feb-12 2:36
mveOriginalGriff13-Feb-12 2:36 
GeneralRe: Do you want string or string? Pin
KP Lee14-Feb-12 14:15
KP Lee14-Feb-12 14:15 
GeneralRe: Do you want string or string? Pin
KP Lee14-Feb-12 14:21
KP Lee14-Feb-12 14:21 
GeneralRe: Do you want string or string? Pin
BobJanova13-Feb-12 3:48
BobJanova13-Feb-12 3:48 
GeneralRe: Do you want string or string? Pin
BotCar13-Feb-12 18:56
BotCar13-Feb-12 18:56 
JokeRe: Do you want string or string? Pin
ZurdoDev13-Feb-12 5:53
professionalZurdoDev13-Feb-12 5:53 
JokeRe: Do you want string or string? Pin
BotCar13-Feb-12 19:06
BotCar13-Feb-12 19:06 
GeneralRe: Do you want string or string? Pin
KP Lee14-Feb-12 15:28
KP Lee14-Feb-12 15:28 
GeneralRe: Do you want string or string? Pin
KP Lee14-Feb-12 14:30
KP Lee14-Feb-12 14:30 
GeneralRe: Do you want string or string? Pin
Brisingr Aerowing31-Mar-12 7:04
professionalBrisingr Aerowing31-Mar-12 7:04 
GeneralBad filtering Pin
Jtai6-Feb-12 8:12
Jtai6-Feb-12 8:12 
GeneralRe: Bad filtering Pin
ekolis6-Feb-12 10:35
ekolis6-Feb-12 10:35 
GeneralRe: Bad filtering Pin
Jtai6-Feb-12 15:04
Jtai6-Feb-12 15:04 
JokeRe: Bad filtering Pin
AspDotNetDev6-Feb-12 15:24
protectorAspDotNetDev6-Feb-12 15:24 

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.