0
Can Recursion Fail in C#?
I have read several books regarding recursion, and they all said that compilers limit their stack limit. So when the stack is full, the program will say, "Stack overflow." My question: Could this happen in C#? If so, how to solve this issue?
2 Answers
0
Recursion can fail in any programming language. This all depends on how you write your code. For instance, If you created a endless recursive loop the stack will eventually use up all the available memory. It's up to you as the programmer to write good code and test your code for these types of issues.
0
With recursion the general rule of thumb is to avoid it. Recursion is something for mathematicans, not for programmers ;)
Nearly every recursive solution can be rewritten with a loop to avoid the self calling.