久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

        <legend id='dyIk9'><style id='dyIk9'><dir id='dyIk9'><q id='dyIk9'></q></dir></style></legend>

          <bdo id='dyIk9'></bdo><ul id='dyIk9'></ul>
      1. <tfoot id='dyIk9'></tfoot>

        <i id='dyIk9'><tr id='dyIk9'><dt id='dyIk9'><q id='dyIk9'><span id='dyIk9'><b id='dyIk9'><form id='dyIk9'><ins id='dyIk9'></ins><ul id='dyIk9'></ul><sub id='dyIk9'></sub></form><legend id='dyIk9'></legend><bdo id='dyIk9'><pre id='dyIk9'><center id='dyIk9'></center></pre></bdo></b><th id='dyIk9'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='dyIk9'><tfoot id='dyIk9'></tfoot><dl id='dyIk9'><fieldset id='dyIk9'></fieldset></dl></div>
      2. <small id='dyIk9'></small><noframes id='dyIk9'>

        如何在 C# 中對兩個字典中的值求和?

        How do I sum values from two dictionaries in C#?(如何在 C# 中對兩個字典中的值求和?)

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

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

                  <bdo id='ETn8M'></bdo><ul id='ETn8M'></ul>
                  <tfoot id='ETn8M'></tfoot>
                • <legend id='ETn8M'><style id='ETn8M'><dir id='ETn8M'><q id='ETn8M'></q></dir></style></legend>
                    <tbody id='ETn8M'></tbody>
                  本文介紹了如何在 C# 中對兩個字典中的值求和?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我有兩個結構相同的字典:

                  I have two dictionaries with the same structure:

                  Dictionary<string, int> foo = new Dictionary<string, int>() 
                  {
                      {"Table", 5 },
                      {"Chair", 3 },
                      {"Couch", 1 }
                  };
                  
                  Dictionary<string, int> bar = new Dictionary<string, int>() 
                  {
                      {"Table", 4 },
                      {"Chair", 7 },
                      {"Couch", 8 }
                  };
                  

                  我想將字典的值相加并返回帶有鍵的第三個字典,以及每個鍵的總值:

                  I'd like to sum the values of the dictionaries together and return a third dictionaries with the keys, and the total values for each key:

                  Table, 9
                  Chair, 10
                  Couch, 9
                  

                  我目前的解決方案是遍歷字典并以這種方式將它們拉出,但我知道該解決方案不是性能最高或可讀性最強的解決方案.但是,我在嘗試在 LINQ 中提出解決方案時遇到了困難.

                  My current solution is to loop through the dictionary and pull them out that way, but I know that solution isn't the most performant or most readable. However, I'm hitting a brick wall trying to come up with a solution in LINQ.

                  推薦答案

                  以下不是最有效的解決方案(因為它只是將兩個字典都視為可枚舉),但它會起作用并且很清楚:

                  The following isn't the most efficient solution (because it simply treats both dictionaries as enumerables), but it will work and it is quite clear:

                  Dictionary<string, int> result = (from e in foo.Concat(bar)
                                group e by e.Key into g
                                select new { Name = g.Key, Count = g.Sum(kvp => kvp.Value) })
                                .ToDictionary(item => item.Name, item => item.Count);
                  

                  這篇關于如何在 C# 中對兩個字典中的值求和?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  What are good algorithms for vehicle license plate detection?(車牌檢測有哪些好的算法?)
                  onClick event for Image in Unity(Unity中圖像的onClick事件)
                  Running Total C#(運行總 C#)
                  Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#(單擊帶有 JAvascript.ASP.NET C# 的超鏈接時刪除目錄)
                  asp.net listview highlight row on click(asp.net listview 在單擊時突出顯示行)
                  Calling A Button OnClick from a function(從函數調用按鈕 OnClick)
                    <bdo id='QGOvJ'></bdo><ul id='QGOvJ'></ul>

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

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

                            <tbody id='QGOvJ'></tbody>
                          <legend id='QGOvJ'><style id='QGOvJ'><dir id='QGOvJ'><q id='QGOvJ'></q></dir></style></legend>

                            主站蜘蛛池模板: www.中文字幕 | 久久综合成人精品亚洲另类欧美 | 久草久草久草 | 亚洲人成人一区二区在线观看 | 国产精品日韩欧美一区二区三区 | 午夜影院在线观看视频 | 久久夜色精品国产 | 在线国产一区 | 在线免费看毛片 | 国产精品一区二区三区在线 | 久久99国产精品 | 久草资源在线视频 | 亚洲精品久久嫩草网站秘色 | 国产精品一区在线观看 | 色资源av| 狠狠婷婷综合久久久久久妖精 | 欧美国产视频 | 新av在线| 色婷婷影院 | 一区二区久久精品 | 96久久久久久 | 免费黄色大片 | 亚洲欧美网 | 1000部精品久久久久久久久 | 不卡在线一区 | 中文字幕在线看人 | 欧美国产中文 | 欧美成人不卡 | 久热伊人 | 亚洲成人精品影院 | 欧美xxxx网站 | 日韩视频一区二区三区 | 久久综合成人精品亚洲另类欧美 | 国产色| 欧美一区二区三区在线 | 中文字幕一区二区三区四区 | 亚洲精品久久久久久久久久久 | 精品视频在线免费观看 | 久久av一区二区三区 | 日韩高清一区 | 日韩av在线一区二区三区 |