<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # unchecked(C# 參考) **unchecked** 關鍵字用于取消整型算術運算和轉換的溢出檢查。 在未檢查的上下文中,如果表達式產生的值在目標類型范圍之外,并不會標記溢出。例如,下例中的計算在 **unchecked** 塊或表達式中執行,因此將忽略結果對于整數而言過大這一事實,并會對 int1 賦予值 -2,147,483,639。 ``` unchecked { int1 = 2147483647 + 10; } int1 = unchecked(ConstantMax + 10); ``` 如果移除 **unchecked** 環境,則發生編譯錯誤。因為表達式的各個項都是常數,所以可以在編譯時檢測到溢出。 默認情況下,在編譯時和運行時不檢查包含非常數項的表達式。有關啟用檢查環境的信息,請參見 [checked(C# 參考)](https://msdn.microsoft.com/zh-cn/library/74b4xzyw.aspx)。 因為溢出檢查比較耗時,所以當無溢出危險時,使用不檢查的代碼可以提高性能。但是,如果可能發生溢出,則應使用檢查環境。 此示例演示如何使用 **unchecked** 關鍵字。 ``` class UncheckedDemo { static void Main(string[] args) { // int.MaxValue is 2,147,483,647. const int ConstantMax = int.MaxValue; int int1; int int2; int variableMax = 2147483647; // The following statements are checked by default at compile time. They do not // compile. //int1 = 2147483647 + 10; //int1 = ConstantMax + 10; // To enable the assignments to int1 to compile and run, place them inside // an unchecked block or expression. The following statements compile and // run. unchecked { int1 = 2147483647 + 10; } int1 = unchecked(ConstantMax + 10); // The sum of 2,147,483,647 and 10 is displayed as -2,147,483,639. Console.WriteLine(int1); // The following statement is unchecked by default at compile time and run // time because the expression contains the variable variableMax. It causes // overflow but the overflow is not detected. The statement compiles and runs. int2 = variableMax + 10; // Again, the sum of 2,147,483,647 and 10 is displayed as -2,147,483,639. Console.WriteLine(int2); // To catch the overflow in the assignment to int2 at run time, put the // declaration in a checked block or expression. The following // statements compile but raise an overflow exception at run time. checked { //int2 = variableMax + 10; } //int2 = checked(variableMax + 10); // Unchecked sections frequently are used to break out of a checked // environment in order to improve performance in a portion of code // that is not expected to raise overflow exceptions. checked { // Code that might cause overflow should be executed in a checked // environment. unchecked { // This section is appropriate for code that you are confident // will not result in overflow, and for which performance is // a priority. } // Additional checked code here. } } } ``` ## C# 語言規范 有關詳細信息,請參閱 [C# 語言規范](https://msdn.microsoft.com/zh-cn/library/ms228593.aspx)。該語言規范是 C# 語法和用法的權威資料。 ## 請參閱 [C# 參考](https://msdn.microsoft.com/zh-cn/library/618ayhy6.aspx) [C# 編程指南](https://msdn.microsoft.com/zh-cn/library/67ef8sbd.aspx) [C# 關鍵字](https://msdn.microsoft.com/zh-cn/library/x53a06bb.aspx) [Checked 和 Unchecked(C# 參考)](https://msdn.microsoft.com/zh-cn/library/khy08726.aspx) [checked(C# 參考)](https://msdn.microsoft.com/zh-cn/library/74b4xzyw.aspx)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看