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?

15th Feb 2017, 6:54 AM
Muhammad Hidayat
Muhammad Hidayat - avatar
2 Respuestas
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.
15th Feb 2017, 7:06 AM
ChaoticDawg
ChaoticDawg - avatar
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.
17th Jun 2017, 9:01 AM
Iqon