------------------------------------------------------------------------------Person.cs
在土默特右旗等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站 網(wǎng)站設(shè)計(jì)制作按需網(wǎng)站策劃,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),成都品牌網(wǎng)站建設(shè),營銷型網(wǎng)站,成都外貿(mào)網(wǎng)站建設(shè)公司,土默特右旗網(wǎng)站建設(shè)費(fèi)用合理。
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { public class Person { public string Country { get; private set; } public string Name { get; private set; } public int Age { get; private set; } public Person(string country, string name, int age) { this.Country = country; this.Name = name; this.Age = age; } } }
------------------------------------------------------------------------------主程序
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { //可以用于實(shí)現(xiàn)了IEnumerable<T>的所有類 //一個(gè)鍵關(guān)聯(lián)多個(gè)值 List<Person> lp = new List<Person>(); lp.Add(new Person("中國", "張飛", 40)); lp.Add(new Person("中國", "關(guān)羽", 43)); lp.Add(new Person("中國", "劉備", 45)); lp.Add(new Person("中國", "諸葛亮", 24)); lp.Add(new Person("美國", "豪威爾", 40)); lp.Add(new Person("美國", "奧巴馬", 40)); lp.Add(new Person("朝鮮", "金三胖", 40)); lp.Add(new Person("印度", "印度阿三", 40)); //傳入一個(gè)Person對(duì)象,返回string var t = lp.ToLookup(r => r.Country);//鍵為Country(國家) foreach (Person item in t["中國"])//找到所有為中國的Person對(duì)象 { Console.WriteLine(item.Name); } Console.ReadKey(); } } }
當(dāng)前題目:字典---ToLookup
文章URL:http://bm7419.com/article20/pcgoco.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁設(shè)計(jì)公司、定制網(wǎng)站、網(wǎng)站內(nèi)鏈、品牌網(wǎng)站設(shè)計(jì)、網(wǎng)站維護(hù)、定制開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)