我有一个查询,返回一个列表框中的项目列表,而不是另一个列表。我想将结果放入另一个列表框中,问题是当我尝试将结果放入列表框中时,它们全部都放在同一行上。假设它返回三个结果(project_green Project_blue_ project_red),并将其作为(project_greenproject_blueproject_red)添加到列表框中的一行。我希望每个项目都在自己的行上,但我无法到达那里。
这是我的代码
Dim result As List(Of String) = (From s1 As String In Me.ListBox1.Items Where Not Me.ListBox4.Items.Contains(s1) Select s1).ToList()
ListBox5.Items.Add(String.Join(Environment.NewLine, result))
任何帮助,将不胜感激。
谢谢
This also saves you a bunch of extra memory. There's no need to allocate a
List
when theIEnumerable
result form the linq query will already do on its own.虽然我个人不喜欢查询理解语法,但更喜欢这样写: