c#十进制转换
2024-10-08 01:15:57
1.方法定义
/// <summary>
/// 十进制转换
/// </summary>
/// <param name="hexChar"></param>
/// <returns></returns>
public static int HexChar2Value(string hexChar)
{
switch (hexChar)
{
case "":
case "":
case "":
case "":
case "":
case "":
case "":
case "":
case "":
case "":
return Convert.ToInt32(hexChar);
case "a":
case "A":
return ;
case "b":
case "B":
return ;
case "c":
case "C":
return ;
case "d":
case "D":
return ;
case "e":
case "E":
return ;
case "f":
case "F":
return ;
default:
return ;
}
}
public int Hex2Ten(string hex)
{
int ten = ;
for (int i = , j = hex.Length - ; i < hex.Length; i++)
{
ten += HexChar2Value(hex.Substring(i, )) * ((int)Math.Pow(, j));
j--;
}
return ten;
}
2.方法调用 (ushort)con.Hex2Ten(con.headset_vid), (ushort)con.Hex2Ten(con.headset_pid)
最新文章
- Sublime Text 3实用快捷键大全
- Progress.js – 为页面上的任意对象创建进度条效果
- Win7激活工具|OEM小马激活
- iTool拷贝app到电脑上
- DuiLib学习笔记3——颜色探究
- Visual Studio的Web Performance Test提取规则详解(2)
- 关于软件开发中兼容win7注册表的解决方案
- ASP.NET MVC5学习笔记之Filter提供体系
- RMI、Hessian、Burlap、Httpinvoker、WebService的比较
- iOS开发The Operation couldn&#39;t be completed.(LaunchServicesError error 0.)的解决方法
- w3c School
- 浅谈ST表
- Benchmarking Apache Kafka: 2 Million Writes Per Second (On Three Cheap Machines)
- 如何把web.xml中的context-param、Servlet、Listener和Filter定义添加到SpringBoot中
- JAVA首次课堂测试总结
- f5 主备模式切换
- Codeforces Round #514 (Div. 2) D. Nature Reserve
- 那天有个小孩教我WCF[一][2/3]
- robotium测试创建java文件和junit文件区别
- 调研android开发环境的发展演变