Functional C# by Wisnu Anggoro
Author:Wisnu Anggoro [Anggoro, Wisnu]
Language: eng
Format: mobi, epub
Publisher: Packt Publishing
Published: 2016-12-29T16:00:00+00:00
As you can see, we have an ordered sequence now, but the sorting key is the last character of each element. This is achieved with the help of our custom comparer. Unfortunately, the custom comparer is only available using the fluent syntax. In other words, we can't use it in the query expression method.
When we sort the sequence, we can have more than one comparer as a condition. We can use the ThenBy extension method for the second condition after we call the OrderBy method. Let's take a look at the following code to demonstrate this:
public partial class Program { public static void OrderByThenByOperator() { IEnumerable<string> query = nameList .OrderBy(n => n.Length) .ThenBy(n => n); foreach (string s in query) { Console.WriteLine(s); } } }
From the preceding code, we sort the sequence by the length of each element, and then we sort the result alphabetically. If we call the OrderByThenByOperator() method, we will get the following output:
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
NET | C & C++ Windows Programming |
SQL Server | VBA |
Visual Basic |
Deep Learning with Python by François Chollet(12579)
Hello! Python by Anthony Briggs(9916)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9796)
The Mikado Method by Ola Ellnestam Daniel Brolund(9780)
Dependency Injection in .NET by Mark Seemann(9340)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8303)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7763)
Grails in Action by Glen Smith Peter Ledbrook(7697)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7100)
Microservices with Go by Alexander Shuiskov(6866)
Practical Design Patterns for Java Developers by Miroslav Wengner(6783)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6724)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6419)
Angular Projects - Third Edition by Aristeidis Bampakos(6137)
The Art of Crafting User Stories by The Art of Crafting User Stories(5660)
NetSuite for Consultants - Second Edition by Peter Ries(5591)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5403)
Kotlin in Action by Dmitry Jemerov(5067)
