• <i id='hRXmj'><tr id='hRXmj'><dt id='hRXmj'><q id='hRXmj'><span id='hRXmj'><b id='hRXmj'><form id='hRXmj'><ins id='hRXmj'></ins><ul id='hRXmj'></ul><sub id='hRXmj'></sub></form><legend id='hRXmj'></legend><bdo id='hRXmj'><pre id='hRXmj'><center id='hRXmj'></center></pre></bdo></b><th id='hRXmj'></th></span></q></dt></tr></i><div id='hRXmj'><tfoot id='hRXmj'></tfoot><dl id='hRXmj'><fieldset id='hRXmj'></fieldset></dl></div>
    • <bdo id='hRXmj'></bdo><ul id='hRXmj'></ul>

    <small id='hRXmj'></small><noframes id='hRXmj'>

        <tfoot id='hRXmj'></tfoot><legend id='hRXmj'><style id='hRXmj'><dir id='hRXmj'><q id='hRXmj'></q></dir></style></legend>

      1. 如何一次迭代两个数组?

        时间:2023-08-28

            <tbody id='QSA98'></tbody>

              <i id='QSA98'><tr id='QSA98'><dt id='QSA98'><q id='QSA98'><span id='QSA98'><b id='QSA98'><form id='QSA98'><ins id='QSA98'></ins><ul id='QSA98'></ul><sub id='QSA98'></sub></form><legend id='QSA98'></legend><bdo id='QSA98'><pre id='QSA98'><center id='QSA98'></center></pre></bdo></b><th id='QSA98'></th></span></q></dt></tr></i><div id='QSA98'><tfoot id='QSA98'></tfoot><dl id='QSA98'><fieldset id='QSA98'></fieldset></dl></div>
              <tfoot id='QSA98'></tfoot>
              <legend id='QSA98'><style id='QSA98'><dir id='QSA98'><q id='QSA98'></q></dir></style></legend>
              • <bdo id='QSA98'></bdo><ul id='QSA98'></ul>

                  <small id='QSA98'></small><noframes id='QSA98'>

                  本文介绍了如何一次迭代两个数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我在解析文本文件时构建了两个数组.第一个包含列名,第二个包含当前行的值.我需要一次遍历两个列表来构建地图.现在我有以下内容:

                  I have two arrays built while parsing a text file. The first contains the column names, the second contains the values from the current row. I need to iterate over both lists at once to build a map. Right now I have the following:

                  var currentValues = currentRow.Split(separatorChar);
                  var valueEnumerator = currentValues.GetEnumerator();
                  
                  foreach (String column in columnList)
                  {
                      valueEnumerator.MoveNext();
                      valueMap.Add(column, (String)valueEnumerator.Current);
                  }
                  

                  这很好用,但它并不能完全满足我的优雅感,如果数组的数量大于两个(我偶尔必须这样做),它会变得非常毛茸茸.有没有人有另一个更简洁的成语?

                  This works just fine, but it doesn't quite satisfy my sense of elegance, and it gets really hairy if the number of arrays is larger than two (as I have to do occasionally). Does anyone have another, terser idiom?

                  推荐答案

                  如果列名的个数和每一行的元素个数一样,可以不用for循环吗?

                  if there are the same number of column names as there are elements in each row, could you not use a for loop?

                  var currentValues = currentRow.Split(separatorChar);
                  
                  for(var i=0;i<columnList.Length;i++){
                     // use i to index both (or all) arrays and build your map
                  }
                  

                  这篇关于如何一次迭代两个数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:编写自定义 IEnumerator&lt;T&gt;带迭代器 下一篇:转换此迭代器块如何进行功能更改?

                  相关文章

                  最新文章

                  <small id='5DU1T'></small><noframes id='5DU1T'>

                  <tfoot id='5DU1T'></tfoot>

                  <legend id='5DU1T'><style id='5DU1T'><dir id='5DU1T'><q id='5DU1T'></q></dir></style></legend>
                  • <bdo id='5DU1T'></bdo><ul id='5DU1T'></ul>

                  1. <i id='5DU1T'><tr id='5DU1T'><dt id='5DU1T'><q id='5DU1T'><span id='5DU1T'><b id='5DU1T'><form id='5DU1T'><ins id='5DU1T'></ins><ul id='5DU1T'></ul><sub id='5DU1T'></sub></form><legend id='5DU1T'></legend><bdo id='5DU1T'><pre id='5DU1T'><center id='5DU1T'></center></pre></bdo></b><th id='5DU1T'></th></span></q></dt></tr></i><div id='5DU1T'><tfoot id='5DU1T'></tfoot><dl id='5DU1T'><fieldset id='5DU1T'></fieldset></dl></div>