【问题标题】:How to get the List Index of a List Tuple element如何获取列表元组元素的列表索引
【发布时间】:2019-05-27 06:01:42
【问题描述】:

我创建了一个 List Tuple String int 像这样:

public static List<Tuple<string, int>> myGrid = new List<Tuple<string, int>>();

myGrid.Add(new Tuple<string, int>("Alpha", 159));

我这样做了,因为我需要在我的代码中使用索引。

如何获取Tuple Item1 或Item2 的List 索引?

【问题讨论】:

    标签: c# wpf tuples


    【解决方案1】:
    var indexByItem1 = myGrid.FindIndex(0, t => t.Item1 == "Alpha");
    var indexByItem2 = myGrid.FindIndex(0, t => t.Item2 == 159);
    

    this interactive fiddle

    【讨论】:

      猜你喜欢
      • 2013-12-03
      • 1970-01-01
      • 2011-05-05
      • 1970-01-01
      • 2016-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多