Integral oveflrow - CSharp Language Basics

CSharp examples for Language Basics:Operator

Introduction

At runtime, arithmetic operations on integral types can overflow.

For example, decrementing the minimum possible int value results in the maximum possible int value:

Demo Code

using System;/*  w  w  w  .j a  v  a 2 s  . co m*/
class Test
{
   static void Main(){
      int a = int.MinValue;
      a--;
      Console.WriteLine (a == int.MaxValue); // True
   }
}

Result


Related Tutorials