programming-examples/c-sharp/Exception/C# Program to Demonstrate Exception Handling for Stack Overflow.cs

24 lines
448 B
C#
Raw Normal View History

2019-11-15 12:59:38 +01:00
/*
* C# Program to Demonstrate Exception Handling for Stack Overflow
*/
using System;
class Program
{
static void excep(int value)
{
Console.WriteLine(value);
excep(++value);
}
static void Main()
{
try
{
excep(0);
}
catch (StackOverflowException e)
{
Console.WriteLine(e.Message);
}
}
}