[Solved] Assign character variable (char) with the symbol that has Unicode code in C#

  

3
Topic starter

Please help me declare a character variable (char) and assign it with the symbol that has Unicode code 42 (decimal) using the '\u00XX' syntax, and then print it in C#.

The output must be * symbol

Thanks!

1 Answer
2

Firstly you must, use the Windows calculator to find the hexadecimal representation of 42. It is 2A

Then use the Unicode code  syntax '\u00XX' - so it will look like \u002A (escape sequence). Do not forget to put it in single quotes (strings are in double qoutes)!

and then write the code itself:

using System;
 
class UnicodeCharacter
{
    static void Main()
    {
        char a = '\u002A';
        Console.WriteLine(a);
    }
}
Share: