判斷是否爲數字

判斷是否爲數字
private 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;
}
 

 
發佈了5 篇原創文章 · 獲贊 0 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章