Beispiel #1
0
        /// <summary>
        /// 获取1,2,4 将其转 list
        /// </summary>
        /// <param name="strName"></param>
        /// <param name="splitChar">分割标识符</param>
        /// <param name="filtSame">是否过滤重复</param>
        /// <returns></returns>
        public static List <int> GetFormInts(string strName, string splitChar, bool filtSame)
        {
            List <int> list = new List <int>();

            if (HttpContext.Current.Request.Form[strName] == null)
            {
                return(list);
            }
            var arr  = StringTool.SplitString(GetFormString(strName), splitChar);
            int temp = 0;

            foreach (var i in arr)
            {
                temp = TypeParseHelper.StrToInt(i, int.MinValue);
                if (temp != int.MinValue)
                {
                    if (filtSame && list.Contains(temp))
                    {
                        continue;
                    }
                    list.Add(temp);
                }
            }
            return(list);
        }
Beispiel #2
0
        /// <summary>
        /// 分割字符串
        /// </summary>
        public static List <int> SplitStringListInt(string strContent, string strSplit)
        {
            List <int> lists = new List <int>();

            int temp = int.MinValue;

            if (strContent.IndexOf(strSplit) < 0)
            {
                temp = TypeParseHelper.StrToInt(strContent, temp);
                if (int.MinValue != temp)
                {
                    lists.Add(temp);
                }
                return(lists);
            }
            foreach (string list in Regex.Split(strContent, @strSplit.Replace(".", @"\."), RegexOptions.IgnoreCase))
            {
                temp = TypeParseHelper.StrToInt(list, temp);
                if (int.MinValue != temp)
                {
                    lists.Add(temp);
                }
            }
            return(lists);
        }
Beispiel #3
0
 /// <summary>
 /// 获得指定表单参数的int类型值
 /// </summary>
 /// <param name="strName">表单参数</param>
 /// <param name="defValue">缺省值</param>
 /// <returns>表单参数的int类型值</returns>
 public static int GetFormInt(string strName, int defValue)
 {
     return(TypeParseHelper.StrToInt(HttpContext.Current.Request.Form[strName], defValue));
 }