C#使用linq對數(shù)組進行篩選排序的方法
更新時間:2015年04月02日 10:10:25 作者:令狐不聰
這篇文章主要介紹了C#使用linq對數(shù)組進行篩選排序的方法,實例分析了C#實用linq擴展進行數(shù)組排序的技巧,具有一定參考借鑒價值,需要的朋友可以參考下
本文實例講述了C#使用linq對數(shù)組進行篩選排序的方法。分享給大家供大家參考。具體如下:
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace OrderQueryResults { class Program { static void Main(string[] args) { string[] names = {"kaka","kunka","kumar","James","Smith"}; var queryResults = from n in names where n.StartsWith("k") orderby n select n; Console.WriteLine("Names beginning with k:"); foreach (var item in queryResults) { Console.WriteLine(item); } Console.ReadLine(); } } }
希望本文所述對大家的C#程序設計有所幫助。
相關文章
windows系統(tǒng)下,如何在C#程序中自動安裝字體
在Windows系統(tǒng)中,原有自帶的字體樣式有限,有時候我們的程序會使用到個別稀有或系統(tǒng)不自帶的字體。因此我們需要將字體打包到程序中,當程序啟動時,檢測系統(tǒng)是否有該字體,如果沒有則安裝該字體,也可以動態(tài)加載字體。2020-11-11