private Listnotes = new List (); ... List uniqueBooks = new List (); uniqueBooks = notes.GroupBy( x => x.BookName ).Select( g => new Note { BookName = g.Key } ).ToList(); uniqueBooks.Sort( (x, y ) => x.BookName.CompareTo( y.BookName ) );
Microsoft AX 2012, X++, C#, SQL server, SSRS, Java, JavaFX, Oracle, PL/SQL, Delphi - codes examples, step-by-step tutorials, experiences.
Wednesday, December 22, 2021
c# - How to make generic unique list with GroupBy()
This code make unique book name list + ensures sorting of the list.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment