I want to convert Tuple IEnumerable
to a List<string>
. For example, if there is
public static IEnumerable<Tuple<string, Type>> GetWord(String formula)
how can I pass the enumerable directly into the constructor of a new List<string>
???
Thanks!
Select
is probably what you want
var list = new List<string>(GetWord.Select(x => x.Item1));
With Select
extension method you can convert enumerable of Tuple to the enumerable of string.
And then you can create a List<string>
without explicitly passing enumerable to the List
constructor, but by using ToList
extension method.
var list = GetWord(formula).Select(t => t.Item1).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