July 8, 2020 11:51 PM
c# ref
C++ &
Convert.ToInt64(),如果参数非数值会异常,需要try catch
tryParse
GetType()
int i = 5;
Console.WriteLine( "i is an int? {0}",i.GetType()==typeof(int));
Console.WriteLine( "i is an int? {0}",typeof(int).IsInstanceOfType(i));
public static bool IsNumeric(string value)
{
return Regex.IsMatch(value, @"^[+-]?/d*[.]?/d*$");
}
public static bool IsInt(string value)
{
return Regex.IsMatch(value, @"^[+-]?/d*$");
}
public static bool IsUnsign(string value)
{
return Regex.IsMatch(value, @"^/d*[.]?/d*$");
}
原文:https://www.cnblogs.com/yongchao/p/13270077.html