Click here to Skip to main content
15,910,981 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: Naming ! ! ! Pin
WiGgLr30-Dec-10 0:05
WiGgLr30-Dec-10 0:05 
GeneralRe: Naming ! ! ! Pin
TorstenH.3-Jan-11 4:38
TorstenH.3-Jan-11 4:38 
GeneralRe: Naming ! ! ! Pin
Hooga Booga17-Jan-11 4:59
Hooga Booga17-Jan-11 4:59 
GeneralPerformance Genius Pin
Ibrahim Yusuf25-Dec-10 16:21
Ibrahim Yusuf25-Dec-10 16:21 
GeneralRe: Performance Genius Pin
OriginalGriff25-Dec-10 21:52
mveOriginalGriff25-Dec-10 21:52 
GeneralRe: Performance Genius Pin
#realJSOP26-Dec-10 5:02
professional#realJSOP26-Dec-10 5:02 
GeneralRe: Performance Genius Pin
Alexander Voronin27-Dec-10 0:46
Alexander Voronin27-Dec-10 0:46 
GeneralRe: Performance Genius Pin
fjdiewornncalwe27-Dec-10 5:45
professionalfjdiewornncalwe27-Dec-10 5:45 
GeneralRe: Performance Genius Pin
AspDotNetDev27-Dec-10 7:00
protectorAspDotNetDev27-Dec-10 7:00 
GeneralRe: Performance Genius Pin
Steve Caine27-Dec-10 10:52
Steve Caine27-Dec-10 10:52 
GeneralRe: Performance Genius Pin
BillW3329-Dec-10 4:23
professionalBillW3329-Dec-10 4:23 
GeneralRe: Performance Genius Pin
ghle29-Dec-10 11:17
ghle29-Dec-10 11:17 
GeneralRe: Performance Genius Pin
Steve Caine29-Dec-10 20:02
Steve Caine29-Dec-10 20:02 
GeneralRe: Performance Genius Pin
ely_bob29-Dec-10 7:06
professionalely_bob29-Dec-10 7:06 
GeneralRe: Performance Genius [modified] Pin
#realJSOP2-Jan-11 1:33
professional#realJSOP2-Jan-11 1:33 
GeneralRe: Performance Genius Pin
fjdiewornncalwe2-Jan-11 4:25
professionalfjdiewornncalwe2-Jan-11 4:25 
GeneralRe: Performance Genius Pin
Steve Caine3-Jan-11 10:35
Steve Caine3-Jan-11 10:35 
GeneralRe: Performance Genius Pin
Sander Rossel27-Dec-10 19:47
professionalSander Rossel27-Dec-10 19:47 
GeneralRe: Performance Genius Pin
Ravi Sant27-Dec-10 22:37
Ravi Sant27-Dec-10 22:37 
GeneralRe: Performance Genius Pin
yxhu5-Jan-11 13:10
yxhu5-Jan-11 13:10 
GeneralRe: Performance Genius Pin
Adrian020-Jan-11 1:48
Adrian020-Jan-11 1:48 
GeneralRe: Performance Genius Pin
yxhu23-Jan-11 11:50
yxhu23-Jan-11 11:50 
Adrian0, unfortunately, your solution was invalid.
As ++i will be calculated(increased) before accessing the element of data collection.
container will never have data[0], plus you will receive an out of index exception at the final loop
of this for expression. Say data collection has 4 elements.
Each iteration looks like:

Loop 1, i initialised = 0:
container.Add(data[1]).Items

Loop 2, i initialised = 1:
container.Add(data[2]).Items

Loop 3, i initialised = 2:
container.Add(data[3]).Items

Loop 3, i initialised = 3:
container.Add(data[4]).Items <<< Exception here


When i++ or ++i is within an expression, ++i has the highest priority to get executed bofere the reset of
the expression. In contrast, i++ is get executed after the whole expression has been executed.

container.Add(data[i++].Items) //Get the ith element of data collection, append to container and then increase i by 1
container.Add(data[++i].Items) //Increase i by 1, then get the 1th element of data collection to append to the container.
GeneralRe: Performance Genius Pin
Adrian023-Jan-11 12:44
Adrian023-Jan-11 12:44 
GeneralRe: Performance Genius Pin
yxhu23-Jan-11 13:14
yxhu23-Jan-11 13:14 
GeneralUseless function Pin
musefan23-Dec-10 3:39
musefan23-Dec-10 3:39 

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.