贴代码——从泛型数组中递归删除不符合要求的项

 1/// <summary>
 2        /// 从泛型数组中递归删除不符合要求的项
 3        /// </summary>
 4        /// <param name="infos"></param>
 5        /// <param name="userid"></param>
 6        /// <returns></returns>

 7        public IList<New.Model.Info> CheckGrade(IList<New.Model.Info> infos, int userid,int i)
 8        {
 9            while(i<infos.Count)
10            {
11                int grade = infos[i].Grade;
12                bool flag = false;
13                switch (grade)
14                {
15                    //do somthing
16                }

17                if (!flag)
18                {
19                    infos.RemoveAt(i);
20                    this.CheckGrade(infos, userid, i);
21                }

22                else 
23                {
24                    i++;
25                }

26            }

27            return infos;
28        }

posted on 2006-08-12 10:31  dnddn  阅读(983)  评论(2编辑  收藏  举报

导航