我有一个包含十进制数的char(string)数组。 如何将其转换为unsigned char?
Assembly myAssembly = Assembly.GetExecutingAssembly();
Stream myStream =
myAssembly.GetManifestResourceStream(myAssembly.GetName().Name +
"pa_logo_notap.png");
Bitmap bmp = new Bitmap(myStream);
Clipboard.SetDataObject(bmp, true);
_xlSheet.Paste(logoRange, bmp);
答案 0 :(得分:1)
将unsigned char value = my_first_reg[0] - '0';
ASCII字符转换为其数字值:
array:4 [▼
0 => array:5 [▼
0 => "some content"
1 => "some content"
2 => "some content"
3 => "some content"
4 => "some content"
]
1 => array:5 [▼
0 => "some content"
1 => "some content"
2 => "some content"
3 => "some content"
4 => "some content"
]
2 => array:6 [▼
0 => "some content"
1 => "some content"
2 => "some content"
3 => "some content"
4 => "some content"
5 => "some content"
]
3 => array:5 [▼
0 => "some content"
1 => "some content"
2 => "some content"
3 => "some content"
4 => "some content"
]
]
这是有效的,因为ASCII表中的数字是连续的:
'0' = 0x30 = 48 '1' = 0x31 = 49 '2' = 0x32 = 50 '3' = 0x33 = 51 '4' = 0x34 = 52 ... '9' = 0x39 = 57