-1

这是代码:

var numbers =
               lightningsRegions.SelectMany(
          s => Regex.Matches(s, @"\[(\d+)[ -]+(\d+)\]")
               .Cast<Match>()
               .Select(m => m.Groups.Cast<Group>().Skip(1).Select(x => x.Value)
                                                          .ToArray())
               .Select(x => new { start = int.Parse(x[0]), end = int.Parse(x[1]) })
               .SelectMany(x => Enumerable.Range(x.start, x.end - x.start + 1))
        )
       .ToList();


                for (int i = 0; i < list_of_histogramsR.Count ; i++)
                {
                  if (list_of_histogramsR[i] == numbers[i])
                    {

                    }
                }

我将变量数视为索引数。最后数字包含5372个数字。所以 thr 5272 中的每个数字就像一个索引。

现在我有这个List<long[]> list_of_histogramsR包含 16595 个索引。我想检查是否有任何数字中的数字list_of_histogramsR作为索引号然后做一些事情。

例如,数字中的第一个数字是 41。因此,当 list_of_histogramsR == 的索引号 41 到数字中的数字 41 时,做一些事情。然后对于变量编号中的下一个数字也是如此。

问题是在 IF 行我得到错误:错误 33 运算符'=='不能应用于'long []'和'int'类型的操作数

为什么 ?

4

1 回答 1

3

您可以使用Contains检查列表是否包含特定数字(将 int 转换为 a long):

list_of_histogramsR[i].Contains((long)numbers[i])
于 2012-12-15T09:23:31.263 回答