Mega Code Archive

 
Categories / C# Tutorial / Data Type
 

Raises the OverflowException exception

using System; class MainClass {    static void Main(string[] args)    {       ushort sh = 2000;       byte sb;       sb = checked((byte)sh);                     Console.WriteLine("sb: {0}", sb);    } } Unhandled Exception: System.OverflowException: Arithmetic operation resulted in an overflow. at MainClass.Main(String[] args)