例如我有一个列表如下:
List<string> myList = new List<string>();
其中包含:
item1
item 2
testing 123
我怎么说:
"where list item contains the value "123" return that item in full"
因此输出结果为:
testing 123
最佳答案
string s = myList.Where(p => p.Contains("123")).SingleOrDefault();
或
string s = myList.SingleOrDefault(p => p.Contains("123"));
关于c# - 在列表中查找项目的特定关键字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11950557/