代码之家  ›  专栏  ›  技术社区  ›  kyrisu

如何从list<tuple<int,int,string>>中获取字符串数组?

  •  5
  • kyrisu  · 技术社区  · 15 年前

    我想知道有没有一种优雅的旅行方式 string[] List<Tuple<int, int, string>> ?

    我在考虑.NET方法(更可取的扩展方法和lambda表达式:p)

    P.S.代码来自.NET 3.5项目,所以tuple是我自己的实现。

    2 回复  |  直到 15 年前
        1
  •  10
  •   Jason    15 年前
    var strings = list.Select(item => item.Item3).ToArray();
    
        2
  •  5
  •   Philippe Leybaert    15 年前
    string[] s = tuples.Select((t) => t.Value3).ToArray();
    

    (假设“value3”是元组的第三个值)