看板 C_Sharp 關於我們 聯絡資訊
底下是我自己寫的運算,目的是將2個bytes的變數合起來再進行運算,例如: hi=0x12; lo=0x34; value =0x1234; 請問C#有沒有API可以將非固定大小的ARRAY資料帶進去得到結果呢? 感謝~ private double transFormmat(string Units, byte hi, byte lo) { string hi_str, lo_str; if (Units == "0.1K") { hi_str = Convert.ToString(hi, 16);//十進制轉16進制 lo_str = Convert.ToString(lo, 16);//十進制轉16進制 if (hi <= 0x0F) hi_str = "0" + hi_str; if (lo <= 0x0F) lo_str = "0" + lo_str; string hexString = hi_str + lo_str;//"0F57"; int num = Int32.Parse(hexString, System.Globalization.NumberStyles.HexNumber); return num ; } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 60.251.17.30
DoMau:16^2*hi+lo 試試看 03/07 19:28
wvsrugby:(hi << 8) + lo 試試看 03/07 21:25
hoyuchang:感謝^^ 03/08 10:44
hello1988:BitConverter 提供滿多轉換的API 可以嘗試看看 03/11 23:11