我有一个字符串:
LogoDataStr = "ABC0000"
我想转换为 ASCII 字节,结果应该是:
LogoDataBy[0] = 0x41;
LogoDataBy[1] = 0x42;
LogoDataBy[2] = 0x43;
LogoDataBy[3] = 0x30;
LogoDataBy[4] = 0x30;
LogoDataBy[5] = 0x30;
LogoDataBy[6] = 0x30;
我试过用这种方式:
byte[] LogoDataBy = ASCIIEncoding.ASCII.GetBytes(LogoDataStr);
但我得到的结果是这样的:
LogoDataBy[0] = 0x41;
LogoDataBy[1] = 0x42;
LogoDataBy[2] = 0x43;
LogoDataBy[3] = 0x00;
LogoDataBy[4] = 0x00;
LogoDataBy[5] = 0x00;
LogoDataBy[6] = 0x00;
我的编码有什么问题吗?