问题描述
我想创建一个应用程序,用户将输入一个数字,程序将抛出回一个字给用户
I want to create an application where user would input a number and the program will throw back a character to the user.
编辑:如何反之亦然,改变一个ASCII字符到多少?
How about vice versa, changing a ascii character into number?
推荐答案
您可以使用以下方法之一来数转换为 ASCII / Unicode的/ UTF-16 人物:
You can use one of these methods to convert number to an ASCII / Unicode / UTF-16 character:
您可以使用这些方法将指定的32位有符号整数的值转换为它的Unicode字符:
You can use these methods convert the value of the specified 32-bit signed integer to its Unicode character:
char c = (char)65;
char c = Convert.ToChar(65);
此外,的范围从字节数组的解码成一个字符串:
Also, ASCII.GetString
decodes a range of bytes from a byte array into a string:
string s = Encoding.ASCII.GetString(new byte[]{ 65 });
请记住, ASCIIEncoding
不提供错误检测。任何超过十六进制0x7F的更大字节被解码为Unicode的问号(?)。
Keep in mind that, ASCIIEncoding
does not provide error detection. Any byte greater than hexadecimal 0x7F is decoded as the Unicode question mark ("?").
这篇关于如何将数字转换成ASCII字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!