VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > temp > C#教程 >
  • C#进制转换

字符串转十进制

1
2
3
4
5
6
7
string data = "01 06 00 AA 00 03 E9 EB";
data = data.Replace(" """);
byte[] orderBytes = new byte[data.Length / 2];
for (int i = 0; i < orderBytes.Length; i++)
{
    orderBytes[i] = Convert.ToByte(data.Substring(i * 2, 2), 16);
}

  

十进制转十六进制

string strHex = "";
for(int i=0;i<orderBytes.Length;i++)
{
    strHex+=string.Format("{0:x}",orderBytes[i]).ToString().PadLeft(2, '0');
}

出处:https://www.cnblogs.com/showonce/p/15691846.html


相关教程