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

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # let 子句(C# 參考) 在查詢表達式中,存儲子表達式的結果有時很有用,這樣可以在隨后的子句中使用。可以使用 **let** 關鍵字完成這一工作,該關鍵字可以創建一個新的范圍變量,并且用您提供的表達式的結果初始化該變量。一旦用值初始化了該范圍變量,它就不能用于存儲其他值。但如果該范圍變量存儲的是可查詢的類型,則可以對其進行查詢。 在下面的示例中,以兩種方式使用了 **let**: 1. 創建一個可以查詢自身的可枚舉類型。 2. 使查詢只能對范圍變量 word 調用一次 ToLower。如果不使用 **let**,則必須在 **where** 子句的每個謂詞中調用 ToLower。 ``` class LetSample1 { static void Main() { string[] strings = { "A penny saved is a penny earned.", "The early bird catches the worm.", "The pen is mightier than the sword." }; // Split the sentence into an array of words // and select those whose first letter is a vowel. var earlyBirdQuery = from sentence in strings let words = sentence.Split(' ') from word in words let w = word.ToLower() where w[0] == 'a' || w[0] == 'e' || w[0] == 'i' || w[0] == 'o' || w[0] == 'u' select word; // Execute the query. foreach (var v in earlyBirdQuery) { Console.WriteLine("\"{0}\" starts with a vowel", v); } // Keep the console window open in debug mode. Console.WriteLine("Press any key to exit."); Console.ReadKey(); } } /* Output: "A" starts with a vowel "is" starts with a vowel "a" starts with a vowel "earned." starts with a vowel "early" starts with a vowel "is" starts with a vowel */ ``` ## 請參閱 [C# 參考](https://msdn.microsoft.com/zh-cn/library/618ayhy6.aspx) [查詢關鍵字(C# 參考)](https://msdn.microsoft.com/zh-cn/library/bb310804.aspx) [LINQ 查詢表達式(C# 編程指南)](https://msdn.microsoft.com/zh-cn/library/bb397676.aspx) [Getting Started with LINQ in C#](https://msdn.microsoft.com/zh-cn/library/bb397933.aspx) [如何:在查詢表達式中處理異常(C# 編程指南)](https://msdn.microsoft.com/zh-cn/library/bb513730.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>

                              哎呀哎呀视频在线观看