久久久久久久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>

                            主站蜘蛛池模板: aaa大片免费观看 | 欧美最猛性xxxxx亚洲精品 | 在线观看电影av | 日韩欧美视频在线 | 亚洲精品电影在线观看 | 噜啊噜在线 | 精品1区 | 99视频网站 | 国产激情在线 | 99re视频| 亚洲v日韩v综合v精品v | 国产成人免费视频网站视频社区 | 国产伦一区二区三区四区 | 久久久久久网站 | 91综合网 | 欧美黄色大片在线观看 | 国产一区二区在线看 | 久久精品国产一区二区三区不卡 | 国产一区二区在线看 | 精品国产乱码久久久久久图片 | 成人精品在线视频 | 久久91精品国产一区二区三区 | 久草新在线 | 伊人久久综合 | 91在线网站 | 成人精品一区二区 | 久热中文字幕 | 一级二级三级黄色 | 欧美日韩久久精品 | 精品视频一区二区三区四区 | 国色天香成人网 | 国产高清在线精品一区二区三区 | 欧美在线观看一区二区 | 欧美国产免费 | 中文日本在线 | 国产日韩欧美精品一区二区三区 | 久久ww| 超级乱淫av片免费播放 | 久久精品国产一区二区电影 | 欧美一级久久 | 中文字幕av在线 |