Printing Unicode code point to console using int i

2019-07-14 16:33发布

apologies if this is silly. How do I print a Unicode character, say \u20ac using an integer? So, instead of Console.WriteLine("\u20ac");, I would like to pass the integer 8364. Thanks.

标签: c# unicode
1条回答
啃猪蹄的小仙女
2楼-- · 2019-07-14 17:19

Just cast the number to char which represents a UTF-16 code point:

public static void PrintChar(int codePoint)
{
    Console.WriteLine((char) codePoint);
}

PrintChar(8364);
查看更多
登录 后发表回答