티스토리 뷰

문자 입력시 숫자인지 확인 하여 

true or false 리턴

public static bool CheckIsNum(string value)
{
            string check = value.Trim();
            bool returnVal = false;
            int dotCount = 0;
            for (int i = 0; i < check.Length; i++)
            {
                if (System.Char.IsNumber(check, i))
                    returnVal = true;
                else
                {
                    if (check.Substring(i, 1) == ".")
                    {
                        returnVal = true;
                        dotCount++;
                    }
                    else
                    {
                        returnVal = false;
                        break;
                    } 
                }
            }
            if (dotCount > 1)
            {
                returnVal = false;
            }
            return returnVal;
 }

댓글
최근에 올라온 글
최근에 달린 댓글
글 보관함
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Total
Today
Yesterday