Check int value overflow - CSharp Language Basics

CSharp examples for Language Basics:int

Description

Check int value overflow

Demo Code

using System;/*from  ww  w  . j  a v a  2 s  .  co  m*/
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
   static void Main(string[] args)
   {
      // Multiplying million by million
      int million = 1000000;
      int result = million * million;
      long resultInLong = million * million;
      Console.WriteLine("Million times million: " + result);
      Console.WriteLine("also in long: " + resultInLong);
   }
}

Result


Related Tutorials