5

I was wondering is there an elegant way of geting string[] from List<Tuple<int, int, string>>?

I'm thinking of .NET way (preferable extension methods and lambda expressions :P)

P.S. Code is from .NET 3.5 project, so Tuple is my own implementation.

kyrisu
  • 4,541
  • 10
  • 43
  • 66

2 Answers2

10
var strings = list.Select(item => item.Item3).ToArray();
Jason
  • 28,040
  • 10
  • 64
  • 64
5
string[] s = tuples.Select((t) => t.Value3).ToArray();

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

Philippe Leybaert
  • 168,566
  • 31
  • 210
  • 223