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 must do is extend the IEnumerable<T> type.

Tip

Good Practice

Put your own extension methods in a separate class library so that they can be easily deployed as their own assembly or NuGet package.

In either Visual Studio 2017 or Visual Studio Code, open the Ch09_LinqToObjects project or folder, and add a new class file named MyLINQExtensions.cs.

Modify the class to look like the following code. Note that the ProcessSequence extension method doesn't modify the sequence because it exists only as an example. It would be up to you to process the sequence in ...

Get C# 7 and .NET Core: Modern Cross-Platform Development - Second Edition 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.