CSharp - Integral Types Division

Introduction

The integral types are int, uint, long, ulong, short, ushort, byte and sbyte.

Division operations on integral types truncate remainders.

Dividing by a variable whose value is zero generates a runtime error DivideByZeroException.

Demo

using System;
class MainClass/*from   ww  w  .ja v  a2 s.com*/
{
   public static void Main(string[] args)
   {
         int a = 2 / 3;      // 0
         Console.WriteLine(a);
         
         int b = 0;
         int c = 5 / b;      // throws DivideByZeroException
         Console.WriteLine(c);

   }
}

Result

Quiz