Namespace microshaoft {using system; using system. LINQ; using system. threading. tasks; using system. threading; using system. collections. generic; using system. collections. concurrent; Class program {static void main (string [] ARGs) {var list = new list <employee> () {New Employee () {id = 100, name = "Bill Gates", Department = "Microsoft"}, new employee () {id = 2, name = "Steve Jobs", Department = "apple "}, new Employee () {id = 300, name = "Larry Page", Department = "google"}, new employee () {id = 4, name = "Sergey Brin ", department = "google"}, new employee () {id = 300, name = "Larry page2", Department = "google"}, new employee () {id = 4, name = "microshaoft", Department = "Microsoft" }}; var groups = List. tolookup <employee, string> (x => {return X. department;}); groups. asparallel (). withdegreeofparallelism (groups. count ). forall (x) => {console. writeline ("{0}, {1}", thread. currentthread. managedthreadid, X. key); var orderedgroup = x. orderbydescending <employee, int> (XX) => {return xx. ID;}); // orderedgroup. asparallel (). withdegreeofparallelism (1 ). forall // (XXX) => // {// console. writeline ("{0}, {1}", thread. currentthread. managedthreadid, xxx. name); //} //); orderedgroup. tolist (). foreach (XXX) => {console. writeline ("{0}, {1}", thread. currentthread. managedthreadid, xxx. name) ;}); console. readline ();} public class employee {public int ID {Get; set;} public string name {Get; set;} Public String Department {Get; set ;} public String gender {Get; set;} public datetime birthday {Get; Set ;}}}} |