0
点赞
收藏
分享

微信扫一扫

asp.net 判断字符串是否是数字的,int的,整型的


#region 判断字符串是否是数字的


/// <summary>
/// 判断是否是数字
/// </summary>
/// <param name="str">字符串</param>
/// <returns>bool</returns>
public bool IsNumeric(string str)
{
	if (str == null || str.Length == 0)
		return false;
	System.Text.ASCIIEncoding ascii = new System.Text.ASCIIEncoding();
	byte[] bytestr = ascii.GetBytes(str);
	foreach (byte c in bytestr)
	{
		if (c < 48 || c > 57)
		{
			return false;
		}
	}
	return true;
}

#endregion 判断字符串是否是数字的




黑色头发:http://heisetoufa.iteye.com/


举报

相关推荐

0 条评论