Wednesday, 5 October 2016

Check if value is Int - c#

No comments
if (IsInt(Request.QueryString["mayColumn"]))
                    mayColumn = Convert.ToInt32(Request.QueryString["mayColumn"]);


 //check if value is int
        private bool IsInt(string sVal)
        {
            foreach (char c in sVal)
            {
                int iN = (int)c;
                if ((iN > 57) || (iN < 48))
                    return false;
            }
            return true;
        }