·  C# – Syntax – Variables – char

 

- Info:

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

  - char is implicitly converted to ALL other types.

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

 

- Procedure:

  - Create C# Console Application Test.cs.

 

    Test.cs

    using System;

   

    class Test {

   

      static void Main(string[] args) {

   

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

        char    value     = 'A';               //Character.

                value     = (char)65;          //Decimal. Explicit conversion from int.

                value     =  char.Parse("A");  //String.

                value     = '\x0041';          //Hexadecimal.

                value     = '\u0041';          //Unicode.

   

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

        ushort  _ushort   = value;

        int     _int      = value;

        uint    _uint     = value;

        long    _long     = value;

        ulong   _ulong    = value;

        float   _float    = value;

        double  _double   = value;

        decimal _decimal  = value;

   

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

        Console.WriteLine(value);

 

      }

   

    }