Creating your own LINQ extension methods

In Chapter 7, Implementing Interfaces and Inheriting Classes, you learned how to create your own extension methods. To create LINQ extension methods, all you have to do is extend the IEnumerable<T> type.

Add a new Class Library project named Ch09_MyLINQExtensions. Rename the Class1.cs file to MyLINQExtensions.

Modify the class to look like the following code. Note that the ProcessSequence extension method doesn't actually modify the sequence because it exists only as an example. It would be up to you to process the sequence in whatever manner you want. The SummariseSequence extension method also doesn't do anything especially useful. It simply returns the number of items in the sequence by using the built-in ...

Get C# 6 and .NET Core 1.0: Modern Cross-Platform Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.