开发者

delete everything from List<string> with specific string

开发者 https://www.devze.com 2023-02-22 03:50 出处:网络
i have: List&l开发者_JS百科t;string> MyFiles i need to delete everything from this list that has a specific string inside of it

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

精彩评论

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