网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

字典---ToLookup

------------------------------------------------------------------------------Person.cs

在土默特右旗等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都网站设计、成都做网站 网站设计制作按需网站策划,公司网站建设,企业网站建设,成都品牌网站建设,营销型网站,成都外贸网站建设公司,土默特右旗网站建设费用合理。

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)
        {
            //可以用于实现了IEnumerable的所有类
            //一个键关联多个值
            List lp = new List();
            lp.Add(new Person("中国", "张飞", 40));
            lp.Add(new Person("中国", "关羽", 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));

            //传入一个Person对象,返回string
            var t = lp.ToLookup(r => r.Country);//键为Country(国家)
            foreach (Person item in t["中国"])//找到所有为中国的Person对象
            {
                Console.WriteLine(item.Name);
            }
            Console.ReadKey();
        }

    }
}

当前文章:字典---ToLookup
分享路径:http://bjjierui.cn/article/pcgoco.html

其他资讯