Hi, I'm a novice at the C# language and I've run into a bit of a problem. I'm writing a program that simulates the national lottery for a bit of fun and it has a loop in it that is going to need to repeat itself, probably millions of times. This seems to consistently give me Stack Overflow Exceptions though. I was wondering if there was any way to stop this from happening? Here's my code:
Roei BarRank #1,271 · 1.4K reputationPosted Aug 13, 2009, 10:39 AM EDT
0
well, i will try to make you understand this in the following matter...
your code runes numerous times, and the stack keeps filling up since you are not releasing the resources..
what i recommend you todo is the following:
move all possible properties to an internal scope, meaning on each iteration you will actually create new properties and work with them, what this will do is on each iteration it will release the stack and reinsert new data which will disable the option for stack overflow.
hope this makes sense to you
if so dont forget to "mark as accepted answer" :-)
Roei BarRank #1,271 · 1.4K reputationPosted Aug 13, 2009, 10:39 AM EDT
your code runes numerous times, and the stack keeps filling up since you are not releasing the resources..
what i recommend you todo is the following:
move all possible properties to an internal scope, meaning on each iteration you will actually create new properties and work with them, what this will do is on each iteration it will release the stack and reinsert new data which will disable the option for stack overflow.
hope this makes sense to you
if so dont forget to "mark as accepted answer" :-)
Sam Rose3 reputationPosted Aug 13, 2009, 4:54 PM EDT