How to get an array of strings from the list <Tuple <int, int, string >>?

I was wondering if there is an elegant way to get string[]from List<Tuple<int, int, string>>?

I am thinking of a .NET method (preferred extension methods and lambda expressions: P)

PS The code is from the .NET 3.5 project, so Tuple is my own implementation.

+3
source share
2 answers
var strings = list.Select(item => item.Item3).ToArray();
+8
source
string[] s = tuples.Select((t) => t.Value3).ToArray();

(assuming "Value3" is the third value of the tuple)

+4
source

Source: https://habr.com/ru/post/1750671/


All Articles