Practical Recursion with Web Matrix

Recursive methods are those methods that call themselves to solve a number of practical probvlems. like for example managing and displaying heirarchical data. This article will explore scenarios on how to design a recursive helper nd functions that can be used in your website.

To give you an idea, methods can “call themselves” using this code:

@functions{
public static int Add(int number){
if(number > 0){
return number + Add(number -1);
}
return 0;
}
}

 

This method takes and int then repeatedly calls itself then reduce the number by 1 until it reaches zero. It then return the sum of all reductions.

Read the rest of the tutorial here: http://www.mikesdotnetting.com/Article/208/Practical-Recursion-in-ASP.NET-Web-Pages-with-WebMatrix

Leave a Reply

Your email address will not be published. Required fields are marked *