using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; namespace Epost.Common { public class ConvertHexHelper { public static string ConvertString(string value, int fromBase, int toBase) { try { int intValue = Convert.ToInt32(value, fromBase); return Convert.ToString(intValue, toBase).ToUpper(); } catch (Exception e) { LogHelper.WriteLogInfo("转换进制报错:"+e.Message+"初始值:"+value); //throw; return value; } } /// /// 验证字符串是否是数字 /// /// /// public static bool IsNum(string str) { Regex r = new Regex(@"^[+-]?\d*(,\d{3})*(\.\d+)?$"); if (r.IsMatch(str)) { return true; } return false; } } }