获取INT类型的地址栏参数

2010-6-1

 

待验证

 

好人一生平安(498888965)  11:22:04
获取INT类型的地址栏参数
好人一生平安(498888965)  11:22:04
public static int GetIntFromQueryString(string key, int defaultValue)
        {
            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString[key]))
            {
                if (Regex.IsMatch(HttpContext.Current.Request.QueryString[key], @"^[+-]?\d*$"))
                    return int.Parse(HttpContext.Current.Request.QueryString[key]);
                else
                    return defaultValue;
            }
            else
                return defaultValue;
        }

你可能感兴趣的:(int)