AhmedTarekHasan / RecursionVsLoopsComparison

Curse of Recursion in .NET C#

Home Page:https://www.developmentsimplyput.com/post/curse-of-recursion-in-net-c

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Curse of Recursion in .NET C#

Why and How you should always try to replace Recursion with something else in .NET C#


One of the famous mistakes I come across from time to time while performing code reviews is the excessive uncalled-for usages of Recursion.

I can hear someone asking now: What is wrong with Recursion?!!

My answer is: Recursion is not always bad if you know when and how to use it. Sometimes there is some better alternatives which you could be missing.

The main concern about using recursion is that it is too expensive in terms of memory consumption. That’s why you need to be cautious about using it.

You don’t believe me, right? Let me show you an example.


If you are interested into reading more about this topic, you can read the rest of the article.


If you want to support me:

▶ Subscribe to Medium using my referral link
▶ Subscribe to Medium Newsletter
▶ Subscribe to LinkedIn Newsletter
▶ Follow me on Medium
▶ Follow me on Twitter
▶ Follow me on LinkedIn


Authors: