byte overflow with unchecked : byte overflow « Data Type « C# / CSharp Tutorial






using System;

class MainClass
{
  static void Main(string[] args)
  {
    Console.WriteLine("Working with unchecked code");
    try
    {
      unchecked
      {
        byte b5 = 100, b6 = 200;
        byte b4 = (byte)(b5 + b6);
        Console.WriteLine("b4 = {0}", b4);       
      }
    }
    catch(OverflowException e)
    { 
      Console.WriteLine(e.Message);
    }    
  }
}
Working with unchecked code
b4 = 44








2.16.byte overflow
2.16.1.byte overflow with unchecked
2.16.2.Catching an underflow