亚洲一级免费看,特黄特色大片免费观看播放器,777毛片,久久久久国产一区二区三区四区,欧美三级一区二区,国产精品一区二区久久久久,人人澡人人草

C語言

c#查詢關(guān)鍵字之into的使用

時(shí)間:2025-02-04 12:55:35 C語言 我要投稿

c#查詢關(guān)鍵字之into的使用

  引導(dǎo)語:c#借鑒了Delphi的一個(gè)特點(diǎn),與COM(組件對象模型)是直接集成的,而且是微軟公司 .NET windows網(wǎng)絡(luò)框架的主角。以下是小編整理的c#查詢關(guān)鍵字之into的使用,歡迎參考閱讀!

  可以使用 into 上下文關(guān)鍵字創(chuàng)建一個(gè)臨時(shí)標(biāo)識符,以便將 group、join 或 select 子句的結(jié)果存儲到新的標(biāo)識符中。此標(biāo)識符本身可以是附加查詢命令的生成器。在 group 或 select 子句中使用新標(biāo)識符的用法有時(shí)稱為“延續(xù)”。

  示例

  下面的示例演示使用 into 關(guān)鍵字來啟用臨時(shí)標(biāo)識符 fruitGroup,該標(biāo)識符具有推斷類型 IGrouping。通過使用該標(biāo)識符,可以對每個(gè)組調(diào)用 Count 方法,并且僅選擇那些包含兩個(gè)或更多個(gè)單詞的組。

  C# 

  class IntoSample1

  {

  static void Main()

  {

  // Create a data source.

  string[] words = { "apples", "blueberries", "oranges", "bananas", "apricots"};

  // Create the query.

  var wordGroups1 =

  from w in words

  group w by w[0] into fruitGroup

  where fruitGroup.Count() >= 2

  select new { FirstLetter = fruitGroup.Key, Words = fruitGroup.Count() };

  // Execute the query. Note that we only iterate over the groups,

  // not the items in each group

  foreach (var item in wordGroups1)

  {

  Console.WriteLine(" {0} has {1} elements.", item.FirstLetter, item.Words);

  }

  // Keep the console window open in debug mode

  Console.WriteLine("Press any key to exit.");

  Console.ReadKey();

  }

  }

  /* Output:

  a has 2 elements.

  b has 2 elements.

  */

  僅當(dāng)希望對每個(gè)組執(zhí)行附加查詢操作時(shí),才需要在 group 子句中使用 into。

【c#查詢關(guān)鍵字之into的使用】相關(guān)文章:

c#查詢關(guān)鍵字之group子句的使用02-24

c#關(guān)鍵字查詢之select 子句運(yùn)用02-07

c#查詢關(guān)鍵字之join 子句運(yùn)用方法07-01

c#查詢關(guān)鍵字from 子句的用法05-13

c#查詢關(guān)鍵字where 子句的運(yùn)用06-01

c#運(yùn)算符關(guān)鍵字is的使用02-03

c#檢測cpu使用率01-02

java的import關(guān)鍵字的使用05-04

c#中預(yù)處理指令#if的使用02-01