Ejemplo n.º 1
0
        /// <summary>
        /// 字符串数组转换成int集合
        /// </summary>
        /// <param name="strings"></param>
        /// <returns></returns>
        public static List <int> ConvertToIntList(this string[] strings)
        {
            List <int> intList = new List <int>();

            if (strings == null)
            {
                return(intList);
            }
            foreach (string id in strings)
            {
                if (StringHelp.CheckInteger(id))
                {
                    intList.Add(Convert.ToInt32(id));
                }
            }
            return(intList);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 字符串数组转换成long数组
        /// </summary>
        /// <param name="strings"></param>
        /// <returns></returns>
        public static long[] ConvertToLongs(this string[] strings)
        {
            long[] longs = null;
            if (strings == null)
            {
                return(null);
            }
            List <long> list = new List <long>();

            foreach (string id in strings)
            {
                if (StringHelp.CheckInteger(id))
                {
                    list.Add(Convert.ToInt64(id));
                }
            }
            if (list != null && list.Count > 0)
            {
                longs = list.ToArray();
            }
            return(longs);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 字符串数组转换成int数组
        /// </summary>
        /// <param name="strings"></param>
        /// <returns></returns>
        public static int[] ConvertToInts(this string[] strings)
        {
            int[] ints = null;
            if (strings == null)
            {
                return(null);
            }
            List <int> list = new List <int>();

            foreach (string id in strings)
            {
                if (StringHelp.CheckInteger(id))
                {
                    list.Add(Convert.ToInt32(id));
                }
            }
            if (list != null && list.Count > 0)
            {
                ints = list.ToArray();
            }
            return(ints);
        }