小编use*_*071的帖子

如何过滤字符串列表,创建仅包含符合我标准的列表?

在我的应用程序中,我希望程序搜索列表,测试每个列表元素.如果list元素是所需的长度,那么我希望将其插入到新列表中.以下是我已经编写的代码

List<string> foo = new List<string>();
List<string> newFoo = new List<string>();

for (int h = 0; h < l; h++);
{
    // Here I want to search through every element of foo and if the element
    // length is greater than say 5 i want to add it to the newFoo 
}
Run Code Online (Sandbox Code Playgroud)

我不知道如何搜索每个元素和我可以找到的任何示例使用LINQ我不想做,因为我确信有一个更简单的方法.任何帮助非常感谢.

c# string list

-1
推荐指数
1
解决办法
1119
查看次数

标签 统计

c# ×1

list ×1

string ×1