Click here to Skip to main content
15,892,059 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: Ha ha Pin
jhwurmbach5-Jun-07 23:08
jhwurmbach5-Jun-07 23:08 
GeneralRe: Casting true to true! Pin
Sameer Alibhai6-Jun-07 2:11
Sameer Alibhai6-Jun-07 2:11 
GeneralRe: Ha ha Pin
Sylvester george20-Jun-07 2:58
Sylvester george20-Jun-07 2:58 
GeneralEmpty catches’ blocks Pin
Ilya Verbitskiy3-Jun-07 22:03
Ilya Verbitskiy3-Jun-07 22:03 
GeneralRe: Empty catches’ blocks Pin
Pete O'Hanlon3-Jun-07 23:00
mvePete O'Hanlon3-Jun-07 23:00 
GeneralRe: Empty catches’ blocks Pin
ScottM13-Jun-07 23:04
ScottM13-Jun-07 23:04 
GeneralRe: Empty catches’ blocks Pin
NormDroid3-Jun-07 23:08
professionalNormDroid3-Jun-07 23:08 
GeneralRe: Empty catches’ blocks Pin
Mike Dimmick4-Jun-07 1:45
Mike Dimmick4-Jun-07 1:45 
If you have one of those, go hunting for an alternate approach that does not throw an exception.

In .NET 1.x, it appeared there was no way to convert a string to an integer without getting an exception if it failed. However, you could go via the Double type's TryParse method and then cast the Double to an int. Double cannot represent the whole range of a 64-bit integer so this approach isn't suitable for numbers this large.

Thankfully .NET 2.0 added a whole load of TryParse methods for the other basic types. (They do much the same work as the old Double.TryParse).

Stability. What an interesting concept. -- Chris Maunder

GeneralRe: Empty catches’ blocks Pin
Dave Kreskowiak4-Jun-07 4:19
mveDave Kreskowiak4-Jun-07 4:19 
GeneralRe: Empty catches’ blocks Pin
Sameer Alibhai4-Jun-07 13:12
Sameer Alibhai4-Jun-07 13:12 
GeneralRe: Empty catches’ blocks Pin
Dave Kreskowiak4-Jun-07 14:09
mveDave Kreskowiak4-Jun-07 14:09 
GeneralRe: Empty catches’ blocks Pin
ScottM14-Jun-07 20:04
ScottM14-Jun-07 20:04 
GeneralRe: Empty catches’ blocks Pin
Paul Conrad5-Jun-07 5:29
professionalPaul Conrad5-Jun-07 5:29 
GeneralRe: Empty catches’ blocks Pin
Rage4-Jun-07 5:02
professionalRage4-Jun-07 5:02 
GeneralRe: Empty catches’ blocks [modified] Pin
ScottM14-Jun-07 20:00
ScottM14-Jun-07 20:00 
GeneralRe: Empty catches’ blocks Pin
DavidNohejl4-Jun-07 22:52
DavidNohejl4-Jun-07 22:52 
GeneralRe: Empty catches’ blocks Pin
ScottM14-Jun-07 22:59
ScottM14-Jun-07 22:59 
GeneralRe: Empty catches’ blocks Pin
DavidNohejl4-Jun-07 23:20
DavidNohejl4-Jun-07 23:20 
GeneralRe: Empty catches’ blocks Pin
Dan Neely5-Jun-07 2:17
Dan Neely5-Jun-07 2:17 
GeneralRe: Empty catches’ blocks Pin
Kevin McFarlane11-Jun-07 2:42
Kevin McFarlane11-Jun-07 2:42 
GeneralRe: Empty catches’ blocks Pin
PIEBALDconsult5-Jun-07 4:00
mvePIEBALDconsult5-Jun-07 4:00 
GeneralRe: Empty catches’ blocks Pin
Dave Kreskowiak5-Jun-07 4:22
mveDave Kreskowiak5-Jun-07 4:22 
GeneralRe: Empty catches’ blocks Pin
PIEBALDconsult5-Jun-07 4:43
mvePIEBALDconsult5-Jun-07 4:43 
GeneralRe: Empty catches’ blocks Pin
Kevin McFarlane11-Jun-07 2:37
Kevin McFarlane11-Jun-07 2:37 
GeneralRe: Empty catches’ blocks Pin
Kevin McFarlane11-Jun-07 2:32
Kevin McFarlane11-Jun-07 2:32 

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.