[問題] 將陣列裡的元素轉16進制或10進制?
底下是我自己寫的運算,目的是將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
推
03/07 19:28, , 1F
03/07 19:28, 1F
→
03/07 21:25, , 2F
03/07 21:25, 2F
→
03/08 10:44, , 3F
03/08 10:44, 3F
推
03/11 23:11, , 4F
03/11 23:11, 4F
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章