I have a list of string, and I want to get all elements that contain a certain string, and get a new list.
Say, myList has the following elements in this order:
(0): “faknknf X1 fnk”
(1): “grnk X2 gknr”
(2): “gnkew X1 hlmlw”
(3): “ifneic X1 lwcgrgs”
(4): “efkncaw X2 gknek”
Now, I want a new list OR it would be great if I could reuse the same list (=myList), that contains elements that contain “X1”. So the new list should be like
(0): “faknknf X1 fnk”
(1): “gnkew X1 hlmlw”
(2): “ifneic X1 lwcgrgs”
And I tried using Linq like the following:
myList.Select(Function(x) x.Contains(“X1”)).ToList
I am assigning this to another new list of string, but it says “Cannot convert IEnumerable (Of Boolean) into List(Of String)”. Why does it do this? I thought this code would select elements that match the condition…