This is the example of the unchecked statement of C#.
In this program we can see the unchecked statement ignores the stack overflow exception and executes the program but the answer which will b show in the output it may be wrong...
ENJOY CODING !!!!
_________________________________________________________________________________
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Unchecked_statement
{
class PostSlush
{
public static void Main(string[] args)
{
int no;
// assign maximum value
no = int.MaxValue;
try
{
unchecked
{
// forces stack overflow exception
no = no + 10;
Console.WriteLine(no);
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
Console.ReadLine();
}
}
}
Output :
Tags:
csharp.net