Click here to Skip to main content
15,886,963 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: Because Reasons Pin
loctrice29-Jul-16 16:19
professionalloctrice29-Jul-16 16:19 
GeneralRe: Because Reasons Pin
Ravichanadeepakarandescarar29-Jul-16 16:39
Ravichanadeepakarandescarar29-Jul-16 16:39 
GeneralRe: Because Reasons Pin
loctrice29-Jul-16 17:50
professionalloctrice29-Jul-16 17:50 
GeneralRe: Because Reasons Pin
Vander Wunderbar31-Jul-16 11:37
Vander Wunderbar31-Jul-16 11:37 
GeneralRecursion schmecursion! Pin
PIEBALDconsult14-Jul-16 16:53
mvePIEBALDconsult14-Jul-16 16:53 
GeneralRe: Recursion schmecursion! Pin
Super Lloyd14-Jul-16 17:15
Super Lloyd14-Jul-16 17:15 
GeneralRe: Recursion schmecursion! Pin
Brisingr Aerowing14-Jul-16 17:28
professionalBrisingr Aerowing14-Jul-16 17:28 
GeneralRe: Recursion schmecursion! Pin
PIEBALDconsult14-Jul-16 18:50
mvePIEBALDconsult14-Jul-16 18:50 
Only in how it works; not in what it does.

I don't think that will work with TreeNodes because TreeNodes are not themselves IEnumerable and the Nodes property is a non-generic IEnumerable.
I can't even add that finally because IEnumerator (the non-generic one) is not IDisposable.
The Nodes Property also has the benefit of never being null, and the TreeNodeCollection has a Count Property.

What I'm doing also needs to know the stack depth for each Node.
There are other things that are unique to what I'm doing that a general method like that is unlikely to support.
And mine uses only one while loop and one Peek. Why are they so wasteful? Big Grin | :-D

And, yes, I made an Extension Method for TreeNodes -- it's an alternative to ToString().


Thanks for showing me that. Thumbs Up | :thumbsup:
Interesting to see that I'm not the only one to think of this technique.

Hey, that one doesn't yield the root object? I think it needs work.
GeneralRe: Recursion schmecursion! Pin
Brisingr Aerowing15-Jul-16 13:18
professionalBrisingr Aerowing15-Jul-16 13:18 
GeneralRe: Recursion schmecursion! Pin
PIEBALDconsult15-Jul-16 13:25
mvePIEBALDconsult15-Jul-16 13:25 
GeneralRe: Recursion schmecursion! Pin
Bernhard Hiller17-Jul-16 22:04
Bernhard Hiller17-Jul-16 22:04 
GeneralRe: Recursion schmecursion! Pin
PIEBALDconsult18-Jul-16 3:32
mvePIEBALDconsult18-Jul-16 3:32 
GeneralFound in old code PinPopular
Sanjay K. Gupta1-Jul-16 1:12
professionalSanjay K. Gupta1-Jul-16 1:12 
GeneralRe: Found in old code Pin
phil.o1-Jul-16 3:13
professionalphil.o1-Jul-16 3:13 
JokeRe: Found in old code Pin
ZurdoDev1-Jul-16 3:24
professionalZurdoDev1-Jul-16 3:24 
GeneralRe: Found in old code Pin
Rob Grainger14-Jul-16 4:39
Rob Grainger14-Jul-16 4:39 
GeneralRe: Found in old code Pin
BillW331-Jul-16 4:32
professionalBillW331-Jul-16 4:32 
GeneralRe: Found in old code Pin
Bernhard Hiller3-Jul-16 22:21
Bernhard Hiller3-Jul-16 22:21 
GeneralRe: Found in old code Pin
Sanjay K. Gupta4-Jul-16 2:44
professionalSanjay K. Gupta4-Jul-16 2:44 
GeneralRe: Found in old code Pin
F-ES Sitecore6-Jul-16 22:49
professionalF-ES Sitecore6-Jul-16 22:49 
GeneralRe: Found in old code Pin
Sanjay K. Gupta7-Jul-16 0:34
professionalSanjay K. Gupta7-Jul-16 0:34 
JokeRe: Found in old code Pin
Kyle Moyer6-Jul-16 10:30
Kyle Moyer6-Jul-16 10:30 
GeneralRe: Found in old code Pin
Mohibur Rashid5-Jul-16 19:20
professionalMohibur Rashid5-Jul-16 19:20 
GeneralRe: Found in old code Pin
PIEBALDconsult9-Jul-16 9:35
mvePIEBALDconsult9-Jul-16 9:35 
GeneralRe: Found in old code Pin
Sanjay K. Gupta10-Jul-16 18:49
professionalSanjay K. Gupta10-Jul-16 18:49 

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.