C# sscanf 問題, thanks!

2007-06-09 12:36 am
How to convert byte[] toConvert = {0x01, 0x0a}

to

byte converted = {0x1a} in C#?

i have tried to use string.Format, but still cannot convert it easily.

回答 (1)

2007-06-09 1:18 am
✔ 最佳答案
Try this:

a3 = ((a1 & 0x0f) << 4) | (a2 & 0x0f);

2007-06-08 17:24:44 補充:
Sorry, 更正:a3 = ((a1 & 0x0f) &lt;&lt; 4) | ((a2 & 0x0f) + 9);
參考: 個人意見


收錄日期: 2021-04-13 00:56:13
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20070608000051KK02259

檢視 Wayback Machine 備份