Possible Duplicate:
Linq: List of lists to a long list
I have convert it using LINQ.List<List<string>>
to List<string>.
If the leaves overlap one. Must be In one line.
When you convert a list into a set, all the duplicates will be removed. The set can then be converted back into a list with list() . The drawback of this method is that the use of set() also changes the original list order, which is not restored after it is converted back into a list.
input.SelectMany(l => l).Distinct().ToList();
Your question is a bit under specified.
input.SelectMany(list=>list).ToList()
This puts all strings that are part of any list into the result list. If you need only unique elements add .Distinct
between the SelectMany
and the ToList
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With