[問題] 透過Lambda過濾資料...
我定義一個物件,裡面有以下資訊...
public class Person {
public string Name;
public int Age;
public string Sex;
};
我使用一個List容器來裝此物件...
List<Person> PerList = new List<Person>(){
new Person(){ Name = "Sam", Age = 50, Sex = "Man" },
new Person(){ Name = "Amy", Age = 30, Sex = "Woman"},
new Person(){ Name = "Andy", Age = 30, Sex = "Man"},
new Person(){ Name = "Jacky", Age = 60, Sex = "Man"},
new Person(){ Name = "Peter", Age = 65, Sex = "Man"},
new Person(){ Name = "Susan", Age = 45, Sex = "Woman"},
new Person(){ Name = "Jeff", Age = 65, Sex = "Man"},
new Person(){ Name = "Mary", Age = 63, Sex = "Woman" };
假設,我有一組資料如上,而我希望可以直接過濾掉其他不需要的資料。
我希望可以"保留" Age 前三名最大的...
也就是說,剩下Mary,Jacky,Peter,Jeff...
想請問一下,如果透過Lambda或是LINQ有辦法過濾出前三名Age最大的嗎??
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.142.153.51
※ 文章網址: https://www.ptt.cc/bbs/C_Sharp/M.1460732888.A.F48.html
推
04/15 23:21, , 1F
04/15 23:21, 1F
→
04/15 23:31, , 2F
04/15 23:31, 2F
→
04/15 23:32, , 3F
04/15 23:32, 3F
推
04/15 23:36, , 4F
04/15 23:36, 4F
推
04/15 23:46, , 5F
04/15 23:46, 5F
推
04/15 23:46, , 6F
04/15 23:46, 6F
→
04/15 23:46, , 7F
04/15 23:46, 7F
→
04/15 23:46, , 8F
04/15 23:46, 8F
→
04/15 23:46, , 9F
04/15 23:46, 9F
→
04/15 23:46, , 10F
04/15 23:46, 10F
→
04/15 23:47, , 11F
04/15 23:47, 11F
推
04/15 23:50, , 12F
04/15 23:50, 12F
→
04/16 03:49, , 13F
04/16 03:49, 13F
→
04/16 03:52, , 14F
04/16 03:52, 14F
→
04/16 07:07, , 15F
04/16 07:07, 15F
→
04/16 07:07, , 16F
04/16 07:07, 16F
推
04/16 11:36, , 17F
04/16 11:36, 17F
→
04/16 11:36, , 18F
04/16 11:36, 18F
→
04/16 11:36, , 19F
04/16 11:36, 19F
→
04/16 11:37, , 20F
04/16 11:37, 20F
→
04/16 11:37, , 21F
04/16 11:37, 21F
→
04/16 11:38, , 22F
04/16 11:38, 22F
→
04/16 11:38, , 23F
04/16 11:38, 23F
→
04/16 11:39, , 24F
04/16 11:39, 24F
→
04/16 11:58, , 25F
04/16 11:58, 25F
→
04/16 13:58, , 26F
04/16 13:58, 26F
→
04/16 13:59, , 27F
04/16 13:59, 27F
→
04/16 13:59, , 28F
04/16 13:59, 28F
→
04/16 13:59, , 29F
04/16 13:59, 29F
→
04/16 14:00, , 30F
04/16 14:00, 30F
→
04/16 14:11, , 31F
04/16 14:11, 31F
推
04/16 21:13, , 32F
04/16 21:13, 32F
→
04/16 21:13, , 33F
04/16 21:13, 33F
→
04/16 21:38, , 34F
04/16 21:38, 34F
推
04/16 23:03, , 35F
04/16 23:03, 35F
→
04/17 00:48, , 36F
04/17 00:48, 36F
→
04/17 00:50, , 37F
04/17 00:50, 37F
→
04/17 00:50, , 38F
04/17 00:50, 38F
→
04/17 00:51, , 39F
04/17 00:51, 39F
→
04/17 00:51, , 40F
04/17 00:51, 40F
→
04/17 00:54, , 41F
04/17 00:54, 41F
→
04/17 01:01, , 42F
04/17 01:01, 42F
→
04/18 23:11, , 43F
04/18 23:11, 43F
→
04/18 23:12, , 44F
04/18 23:12, 44F
→
04/18 23:12, , 45F
04/18 23:12, 45F
推
04/19 01:15, , 46F
04/19 01:15, 46F
推
04/19 21:20, , 47F
04/19 21:20, 47F
→
04/19 21:59, , 48F
04/19 21:59, 48F
→
04/19 21:59, , 49F
04/19 21:59, 49F
推
04/20 15:45, , 50F
04/20 15:45, 50F
推
04/26 14:23, , 51F
04/26 14:23, 51F
→
04/27 09:11, , 52F
04/27 09:11, 52F
推
05/17 16:04, , 53F
05/17 16:04, 53F
推
05/24 13:44, , 54F
05/24 13:44, 54F
推
09/26 15:23, , 55F
09/26 15:23, 55F
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章