·  C# – Syntax – Variables – int

 

- Info:

  - This tutorial shows how to create, convert and display int.

  - int is implicitly converted to: long, float, double and decimal.

  - This tutorial is based on http://msdn.microsoft.com/en-us/library/5kzh1b5w(VS.80).aspx.

 

- Procedure:

  - Create C# Console Application Test.cs.

 

    Test.cs

    using System;

   

    class Test {

   

      static void Main(string[] args) {

   

        //CREATE.------------------------------------------------------------------------

        int     value    = -10;               //Decimal.

                value    = -0xA;              //Hexadecimal.

   

        //CONVERT.-----------------------------------------------------------------------

        char    _char    = (char  ) value;

   

        sbyte   _sbyte   = (sbyte ) value;

        short   _short   = (short ) value;

        long    _long    =          value;

   

        byte    _byte    = (byte  ) value;    //246

        ushort  _ushort  = (ushort) value;    //65526

        uint    _uint    = (uint  ) value;    //4294967286

        ulong   _ulong   = (ulong ) value;    //18446744072709551606

   

        float   _float   =          value;

        double  _double  =          value;

        decimal _decimal =          value;

        

        //DISPLAY.-----------------------------------------------------------------------

        Console.WriteLine(value);    

 

      }

   

    }