开发者

delete everything from List<string> with specific string

i have:

List&l开发者_JS百科t;string> MyFiles

i need to delete everything from this list that has a specific string inside of it

for example if the list was:

alex1
alex123
alex234
alex345

and i would like to delete every element in this list that has the string "1" in it?


MyFiles.RemoveAll(s => s.Contains("1"));


Does this work for you?

C#

MyFiles.RemoveAll((string s) => s.Contains("1"))

I code in VB.NET:

MyFiles.RemoveAll(Function(s As String) s.Contains("1"))

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜