染色机计算机
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

37 lines
1.1 KiB

using System;
namespace DyeingComputer.UserClass
{
/// <summary>
/// 字符串转数字
/// </summary>
internal class StrToInt
{
/// <summary>
/// 十六进制字符串转十进制
/// </summary>
/// <param name="str">十六进制字符</param>
/// <returns></returns>
public static int To16Convert10(string str)
{
int res = 0;
try
{
str = str.Trim().Replace(" ", ""); //移除空字符
//方法1
res = int.Parse(str, System.Globalization.NumberStyles.AllowHexSpecifier);
//方法2
//int r2 = System.Int32.Parse(str, System.Globalization.NumberStyles.HexNumber);
//Console.WriteLine(r2);
//方法3
//int r3 = Convert.ToInt32(str, 16);
//Console.WriteLine(r3);
}
catch (Exception)
{
res = 0;
}
return res;
}
}
}