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"))
精彩评论