mirror of https://github.com/leiurayer/downkyi
30 lines
685 B
30 lines
685 B
using System.Text.RegularExpressions;
|
|
|
|
namespace DownKyi.Core.Utils.Validator
|
|
{
|
|
public static class Number
|
|
{
|
|
|
|
/// <summary>
|
|
/// 字符串转数字(长整型)
|
|
/// </summary>
|
|
/// <param name="value"></param>
|
|
/// <returns></returns>
|
|
public static long GetInt(string value)
|
|
{
|
|
return IsInt(value) ? long.Parse(value) : -1;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否为数字
|
|
/// </summary>
|
|
/// <param name="value"></param>
|
|
/// <returns></returns>
|
|
public static bool IsInt(string value)
|
|
{
|
|
return Regex.IsMatch(value, @"^\d+$");
|
|
}
|
|
|
|
}
|
|
}
|