Search code examples
c#charascii

what is ASCII code for right filled arrow " ►"


I am trying to print right filled arrow ► in C# this is I tried

 static void Main(string[] args) {
   Console.WriteLine((char)16);
 }

but it is showing the output as ? (question mark) I have gone through this question also but the it doesn't seem to work. Can you help me with correct ASCII code which shows the correct output?


Solution

  • You can easily convert char to int and thus obtain its code:

      char arrow = '►'; // Copy + Paste from the question
    
      Console.Write($"{arrow} : {(int)arrow} : \\u{(int)arrow:X4}";);
    

    Outcome:

      ► : 9658 : \u25BA
    

    and that's why you can put

      char arrow = '\u25BA';