久久人人97超碰超碰窝窝_国产精品久久久久久搜索_AV在线网站无码不卡的_亚洲AV永久精品爱情岛论坛

rexian

咨詢電話:023-6276-4481

熱門文章

聯(lián)系方式

電 話:023-6276-4481

郵箱:broiling@qq.com

地址:重慶市南岸區(qū)亞太商谷6幢25-2

當前位置:網(wǎng)站首頁 > 技術(shù)文章 > c# GroupBy的動態(tài)拼接

c# GroupBy的動態(tài)拼接

編輯:pansiqin 發(fā)表時間:2017-12-04 14:00:30
pansiqin

public class Person
{    public string FirstName{set;get;}    public string LastName{set;get;}    public Person(){}    public Person(string firstName, string lastName)
    {
        FirstName = firstName;
        LastName = lastName;
    }
}

List<Person> personList=new List<Person>();
personList.Add(new Person() { FirstName = "Mickey", LastName = "Mouse" });
personList.Add(new Person() { FirstName = "Mickey", LastName = "Mouse" });
personList.Add(new Person() { FirstName = "zhang", LastName = "san" });string columnName="FirstName";var dics=personList.GroupBy(x => GetPropertyValue(x, columnName)).ToDictionary(x=>x.Key,x=>x.Count());foreach(var dic in dics)
{
    textBox1.AppendText(string.Format("{0},{1}\r\n",dic.Key,dic.Value));
}