添加项目文件。
This commit is contained in:
44
Common/ConvertHexHelper.cs
Normal file
44
Common/ConvertHexHelper.cs
Normal file
@ -0,0 +1,44 @@
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 验证字符串是否是数字
|
||||
/// </summary>
|
||||
/// <param name="str"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsNum(string str)
|
||||
{
|
||||
Regex r = new Regex(@"^[+-]?\d*(,\d{3})*(\.\d+)?$");
|
||||
if (r.IsMatch(str))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user