我有一个列表:
List(Of String)
我想用 LINQ 过滤它。
我使用这样的东西:
newList = (From l In myList Where l Like String.Format("%{0}%", value)).ToList
值类似于a
或no
等。
我想要类似 SQL 中的 LIKE
的东西:
like "%a%"
所以我将生成一个字符串列表,其中每个字符串中都有一个 a
。
我应该怎么做?
dim list1 as list(of string)
list1.Add("aaa")
list1.Add("bbb")
list1.Add("ccc")
list1.Add("abc")
list1 = from l in list1 where ???? 'like "a" return list1 with 2 item : "aaa" and "abc"
最佳答案
List a = new List();
a = a.Where(item => item.contains("a")).ToList();
关于linq列表字符串像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10036991/