[Console] 숫자만 입력받기

2011. 9. 21. 16:26C#/Console

        public int isNum(string a_str)
        {
            int rc = 0;
            //rc = 0 :문자, 1:정수, 2:실수

            for (int i = 0; i < a_str.Length; i++)
            {
                if ((a_str[i] >= '0' && a_str[i] <= '9') || a_str[i] == '.')
                    rc = 1;
                else
                    rc = 0;
                break;
            }
            if (rc == 1)
                if (a_str.IndexOf(".") >= 0) rc = 2;
            return rc;
        }

'C# > Console' 카테고리의 다른 글

[Console] 기상 방위표  (0) 2012.11.27
[C#] 이동평균  (0) 2011.11.22
[Console] DllImport  (0) 2011.09.14
[Console 08.23] 완벽한 코드  (0) 2011.08.23
[Console] C# 문자 변환  (0) 2011.08.04