我将控制台程序的输入作为“Hai My Name是KrishNA”并将该字符串转换为ascii字符,并且得到的输出为543777096.我想如果我给相同数量的输入我想在同一个程序和空间的ASCII值与上述相同的输出是32,我想跳过space.I写的C#程序下面将字符串转换为ascii和ascii为字符串
string s1;
s1 = Console.ReadLine();
byte[] bytes = Encoding.ASCII.GetBytes(s1);
int result = BitConverter.ToInt32(bytes, 0);
//foreach (int r in bytes)
//{
Console.Write(result);
//}
//byte[] array = new byte[result];
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(s1);
foreach (int a in buffer)
{
Console.WriteLine(buffer);
}
请帮我在这
所以你得到字符的前4个字节(“海”),放下其余的并将其转换为32位整数。你期望什么? – taffer