linq列表字符串像

标签 linq

我有一个列表:

List(Of String)

我想用 LINQ 过滤它。

我使用这样的东西:

newList = (From l In myList Where l Like String.Format("%{0}%", value)).ToList

值类似于ano 等。

我想要类似 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/

相关文章:

jquery - jqGrid 的 LINQ 搜索中的可为 Null 值

c# - 我可以使用 LINQ 改进这个算法吗?

linq - 像 SQL 的 linq 查询和 sql server 2008 的 Soudex 是什么?

sql - 对实体进行分组和求和

c# - 在按钮中检测到 ActionLink 存在潜在危险的 Request.Path 值

C# 选择累加器不工作的重载方法

c# - ToListAsync() in a DbContext using statement : "The ObjectContext disposed", 如何处理?

.net - 带有过滤条件的 LINQ 连接

c# - C# 中的 LINQ to SQL 查询

c# - 使用 LINQ 在一行代码中将 string[] 转换为 int[]