·  C# – Syntax – Variables – double

 

- Info:

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

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

 

- Procedure:

  - Create C# Console Application Test.cs.

 

    Test.cs 

    using System;

   

    class Test {

   

      static void Main(string[] args) {

   

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

        double  value    = 10.5;             //Double real constant.

                value    = 10;               //Decimal.     Implicit conversion from int.

                value    = 0xA;              //Hexadecimal. Implicit conversion from int.

   

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

        char    _char    = (char   ) value;

   

        sbyte   _sbyte   = (sbyte  ) value;

        short   _short   = (short  ) value;

        int     _int     = (int    ) value;

        long    _long    = (long   ) value;

     

        byte    _byte    = (byte   ) value;   

        ushort  _ushort  = (ushort ) value;   

        uint    _uint    = (uint   ) value;   

        ulong   _ulong   = (ulong  ) value;   

   

        float   _float   = (float  ) value;

        decimal _decimal = (decimal) value;

        

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

        Console.WriteLine(value);    

 

      }

   

    }