码迷,mamicode.com
首页 > Windows程序 > 详细

C# 中使用对List中的每个元素进行筛选(FindAll)

时间:2018-01-16 11:15:41      阅读:701      评论:0      收藏:0      [点我收藏+]

标签:reac   index   sys   file   code   indexof   read   pre   dal   

使用LIST的方法FindAll. string[] lines = System.IO.File.ReadAllLines(sfile); List<string> rs = new List<string>(lines); length = 25; List<string> ss = rs; if (length > 0) { ss = rs.FindAll(c => c.Length == length); //筛选出长度为25的所有项 } foreach (string t in ks) { ss = ss.FindAll(c => c.IndexOf(t) >= 0); //筛选出说有包含关键词 t 的项 } Lrs = ss;

C# 中使用对List中的每个元素进行筛选(FindAll)

标签:reac   index   sys   file   code   indexof   read   pre   dal   

原文地址:http://blog.51cto.com/13567390/2061422

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!