I'm trying to learn recursion in C#. I am able to do a simple count down in a console application, but I am not sure how to do the same thing in an ASP.NET web application. I would like to display the result in a listbox, but I cannot access the listbox in a static function.
Here is what I have for my console application:
static void Main(string[] args)
{
int startInt = 100;
countDown(startInt);
Console.ReadLine();
}
public static void countDown(int integer)
{
if (integer == 1)
{
Console.WriteLine(integer);
}
else
{
Console.WriteLine(integer);
integer--;
countDown(integer);
}
}
Any help on getting this to work in a web application that will display the numbers in a listbox?