开发者

How to get array of string from List<Tuple<int, int, string>>?

开发者 https://www.devze.com 2023-01-04 11:20 出处:网络
I was wondering is there an elegant way of geting string[] from List<Tuple<int, int, string>>?

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.


var strings = list.Select(item => item.Item3).ToArray();


string[] s = tuples.Select((t) => t.Value3).ToArray();

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

0

精彩评论

暂无评论...
验证码 换一张
取 消