Check number Conversions in CSharp

Description

The following code shows how to check number Conversions.

Example


  //  ww  w. j  a v  a2s. com
  
  
     

using System;

public class UNCheckedConversions
{
    public static void Main()
    {
        uint value1 = 312;
        byte value2;
        
        value2 = unchecked((byte) value1);    // never checked
        value2 = (byte) value1;               // checked if /checked
        value2 = checked((byte) value1);      // always checked
    }
}




















Home »
  C# Tutorial »
    C# Language »




C# Hello World
C# Operators
C# Statements
C# Exception