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

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

      <tfoot id='TmCmi'></tfoot>

      1. <small id='TmCmi'></small><noframes id='TmCmi'>

      2. <legend id='TmCmi'><style id='TmCmi'><dir id='TmCmi'><q id='TmCmi'></q></dir></style></legend>

        LINQ 和溢出異常?

        LINQ Sum OverflowException?(LINQ 和溢出異常?)
      3. <tfoot id='jNsmJ'></tfoot>
        1. <legend id='jNsmJ'><style id='jNsmJ'><dir id='jNsmJ'><q id='jNsmJ'></q></dir></style></legend>

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

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

                • 本文介紹了LINQ 和溢出異常?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我已經(jīng)為 EventLogEntry 實現(xiàn)了一個自定義的 IEqualityComparer.

                  I've implemented a custom IEqualityComparer for EventLogEntry.

                  public class EventLogEntryListComparison :
                      IEqualityComparer<List<EventLogEntry>>,
                      IEqualityComparer<EventLogEntry>
                  

                  對于IEqualityComparer>,GetHashCode函數(shù)很簡單.

                  For IEqualityComparer<List<EventLogEntry>>, the GetHashCode function is very simple.

                  public int GetHashCode(List<EventLogEntry> obj)
                  {
                      return obj.Sum(entry => 23 * GetHashCode(entry));
                  }
                  

                  但是,對于某些條目,這會引發(fā) OverflowException.

                  However, this throws an OverflowException for certain entries.

                  "Arithmetic operation resulted in an overflow."
                     at System.Linq.Enumerable.Sum(IEnumerable`1 source)
                     at System.Linq.Enumerable.Sum[TSource](IEnumerable`1 source, Func`2 selector)
                     at <snip>.Diagnostics.EventLogAnalysis.EventLogEntryListComparison.GetHashCode(List`1 obj) in C:dev<snip>Diagnostics.EventLogAnalysisEventLogEntryListComparison.cs:line 112
                     at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
                     at System.Collections.Generic.Dictionary`2.set_Item(TKey key, TValue value)
                     at <snip>.Diagnostics.EventLogAnalysis.Program.AnalyseMachine(String validMachineName) in C:dev<snip>.Diagnostics.EventLogAnalysisProgram.cs:line 104
                     at System.Threading.Tasks.Parallel.<>c__DisplayClass2d`2.<ForEachWorker>b__23(Int32 i)
                     at System.Threading.Tasks.Parallel.<>c__DisplayClassf`1.<ForWorker>b__c()
                  

                  在調試時嘗試得到相同的錯誤并且無法在即時窗口中出現(xiàn)后,我將代碼更改為這個并再見 OverflowException?

                  After trying to get the same error whilst debugging and couldn't in the immediate window, I changed the code to this and bye bye OverflowException?

                  int total = 0;
                  foreach (var eventLogEntry in obj)
                  {
                      total += GetHashCode(eventLogEntry);
                  }
                  
                  return total;
                  

                  LINQ 的 Sum 函數(shù)有何不同?

                  How is it that LINQ's Sum function behaving differently?

                  編輯 2

                  感謝一些評論,更正和預期的 GetHashCode 函數(shù)現(xiàn)在如下,

                  Thanks to a few comments, the corrected and intended GetHashCode function is now as follows,

                  public int GetHashCode(List<EventLogEntry> obj)
                  {
                      return unchecked(obj.Aggregate(17,
                          (accumulate, entry) =>
                          accumulate * 23 + GetHashCode(entry)));
                  }
                  

                  推薦答案

                  LINQ 的 Enumerable.Sum(...) 方法在 checked 塊內執(zhí)行加法.這意味著如果總和溢出,他們會故意拋出異常.

                  LINQ's Enumerable.Sum(...) methods perform the additions inside a checked block. This means that they deliberately throw an exception if the sum overflows.

                  您的 sum 不在 checked 塊內,因此它是否引發(fā)異常取決于...是從 checked 塊內調用它,還是我相信在程序集上的一個屬性.

                  Your sum is not inside a checked block, so whether or not it throws an exception depends on... whether it is called from inside a checked block, or a property on the assembly I believe.

                  這篇關于LINQ 和溢出異常?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關文檔推薦

                  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(從函數(shù)調用按鈕 OnClick)

                      <bdo id='1JeTf'></bdo><ul id='1JeTf'></ul>

                      1. <tfoot id='1JeTf'></tfoot>

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

                            <tbody id='1JeTf'></tbody>

                          <small id='1JeTf'></small><noframes id='1JeTf'>

                          <legend id='1JeTf'><style id='1JeTf'><dir id='1JeTf'><q id='1JeTf'></q></dir></style></legend>
                          • 主站蜘蛛池模板: 天天干夜夜操 | 免费九九视频 | 自拍偷拍精品 | 亚洲黄色一级 | 久久久91精品国产一区二区三区 | 黄色电影在线免费观看 | 日韩在线免费视频 | 欧美综合一区二区三区 | h在线观看 | 国产精品国产成人国产三级 | 国产一区二区三区网站 | 精品成人免费一区二区在线播放 | 国产精品观看 | 黄色一级免费观看 | 精品国产乱码久久久久久图片 | 日韩午夜在线播放 | 欧美日韩国产不卡 | 在线视频国产一区 | 91香蕉视频在线观看 | 日韩一区中文字幕 | 一区二区三区中文字幕 | 欧美日韩在线精品 | 国产精品久久一区二区三区 | 99在线免费观看 | 久久久www | 九色视频网 | 亚洲免费视频播放 | 亚洲免费在线观看 | 国产午夜亚洲精品不卡 | 国内精品久久久久 | 二区中文| 亚洲精品电影网在线观看 | 亚洲精品乱码久久久久久蜜桃91 | 亚洲高清电影 | 蜜桃一区二区三区在线 | 国产高清免费 | 日韩中文字幕一区二区三区 | 亚洲激情在线 | 国产伦一区二区三区久久 | 午夜三级在线观看 | 久久99这里只有精品 |