How do i get the decimal value of a unicode character in C#?

前端 未结 5 1147
南笙
南笙 2020-12-31 04:48

How do i get the numeric value of a unicode character in C#?

For example if tamil character (U+0B85) given, output should be 2949 (i.e. <

5条回答
  •  天命终不由人
    2020-12-31 05:15

    ((int)'அ').ToString()
    

    If you have the character as a char, you can cast that to an int, which will represent the character's numeric value. You can then print that out in any way you like, just like with any other integer.

    If you wanted hexadecimal output instead, you can use:

    ((int)'அ').ToString("X4")
    

    X is for hexadecimal, 4 is for zero-padding to four characters.

提交回复
热议问题