欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#判斷字符串是否是int/double(實(shí)例)

 更新時(shí)間:2016年12月25日 14:56:04   作者:欣宇  
本文主要分享了C#判斷字符串是否是int/double的具體實(shí)例,具有一定的參考價(jià)值,需要的朋友一起來看下吧

話不多說,請(qǐng)看代碼

using System.Text.RegularExpressions;
/// <summary>
/// 判斷字符串是否是int/double
/// </summary>
public static bool IsIntOrDouble(string strNumber)
{
 Regex objNotNumberPattern = new Regex("[^0-9.-]");
 Regex objTwoDotPattern = new Regex("[0-9]*[.][0-9]*[.][0-9]*");
 Regex objTwoMinusPattern = new Regex("[0-9]*[-][0-9]*[-][0-9]*");
 const string strValidRealPattern = "^([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]+$";
 const string strValidIntegerPattern = "^([-]|[0-9])[0-9]*$";
 Regex objNumberPattern = new Regex("(" + strValidRealPattern + ")|(" + strValidIntegerPattern + ")");
 return !objNotNumberPattern.IsMatch(strNumber) &&
  !objTwoDotPattern.IsMatch(strNumber) &&
  !objTwoMinusPattern.IsMatch(strNumber) &&
  objNumberPattern.IsMatch(strNumber);
}

以上就是本文的全部?jī)?nèi)容,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來一定的幫助,同時(shí)也希望多多支持腳本之家!

相關(guān)文章

最新評(píng)論