簡體   English   中英

將帶字母和數字的字符串轉換為僅十進制數字

[英]Converting string with letters and numbers to decimal only numbers

我正在使用RFID Reader ,后來成為一個軟件演示,該演示具有讀取rfid tag幾種不同類型,例如:

HexadecimalDecimalAsciiAbatrack等...

Abatrack文檔說:

Shows the CardID converted to decimal with 14 digits

我有一個01048CABFB = 01048CABFB然后使用此協議,它向我顯示00004371295227
where the first four zeroes were added by the software

它將包含字母和數字的string轉換為僅包含數字的decimal 我該怎么辦?

我發現 ,但它在VB

要將十六進制轉換為十進制,可以執行以下操作:

string hexString = "01048CABFB";
long intVal = Int64.Parse(hexString, System.Globalization.NumberStyles.HexNumber);
// intVal = 4371295227

您還可以使用Convert.ToInt64(),它允許您指定以16為基數(十六進制):

        string hexFromRFID = "01048CABFB";
        Int64 decFromRFID = Convert.ToInt64(hexFromRFID, 16);
        Console.WriteLine("Hex: " + hexFromRFID + " = Dec: " + decFromRFID);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM