[C#] C#通过linq语句查询数组中以特定字符开头的元素 →→→→→进入此内容的聊天室

来自 , 2020-07-22, 写在 C#, 查看 172 次.
URL http://www.code666.cn/view/d6317f80
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. static void Main(string[] args)
  7. {
  8.     string[] names = { "kaka", "kunka", "kumar", "James", "Smith"};
  9.     var queryResults =
  10.     from n in names
  11.     where n.StartsWith("k")
  12.     select n;
  13.     Console.WriteLine("Names beginning with K:");
  14.     foreach (var item in queryResults) {
  15.         Console.WriteLine(item);
  16.     }
  17.     Console.ReadLine();
  18. }
  19.  
  20.  
  21. //csharp/7789

回复 "C#通过linq语句查询数组中以特定字符开头的元素"

这儿你可以回复上面这条便签

captcha