1publicclass Person:basedomain 2 {3long _id; 4string firstName; 5string secondname; 6string comments; 7 8public Pers On () 9 {}1011public person (long id) {13this._id = id;14}15public person (long id,string firstName, String secondname) + {17this._id = Id;18this.firstname = Firstname;19this.secondname = Secondname;20 Co mments = string.empty;21}22public person (long id,string firstName, String secondname, string comments) 23 : This (id,firstname, secondname) {25this.comments = comments;26}2728publicstring FirstName29 {3 0get {return firstName;} 31set {firstName = value;} }33publicstring SecondName34 {35get {return secondname;} 36set {secondname = value;} PNs}38publicstring Comments39 {40get {return comments;} 41set {comments = value;} }43publicoverridestring ToString () 45returnstring. Format ("FirstName: {0}\tsecondname: {1}\tcomment: {2}", This.firStname, This.secondname, this.comments); 46}47}
View Code
Above is the simple type of test required: person
1var list = new list<person> (5); 2 list. ADD (New person (1, "Bite gold", "Cheng", "the guy with the Axe"); 3 list. ADD (New person (2, "Bite gold", "Cheng", "the guy with the Axe"); 4 list. ADD (New person (3, "Marten Cicada", "King", "3 skill is great"); 5 list. ADD (New Person (4, "Zhao June", "Lee", "Fit to Fight"); 6 list. ADD (New person (5, "Arthur", "Mao", "hard thick meat"); 7 8//to perform a de-redo operation, you need to first introduce the LINQ reference "using System.Linq; "9var result_list = list. GroupBy (obj=>obj. FirstName). Select (G=>g.first ()). ToList (); 1011foreach (var item in result_list) { Console.WriteLine (item);
View Code
The above describes the lambda expression filter that uses lambda expressions to combine objects, including the contents of the lambda expression, in the hope of. NET tutorial interested friends are helpful.