The Operater Checked and Unchecked

   public void main(string[] args)
{        
    Byte b = 255;
            checked
            {
               b++;
             }
         Console.WriteLine(b.ToString());
}
      Results:
         Unhandled Exception :System.OverflowException:Arithmetic opertation resulted in an overflow at ...;
   if you want to forbid it to run
just change checked to Unchecked

Of course The Results Will Lost Date,The Result is Zero;
posted @ 2007-04-02 15:44 DavidYou Views(57) Comments(0) Edit 收藏