From the course: Visual Studio Developer Tips

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

IEnumerable Extension Methods

IEnumerable Extension Methods - Visual Studio Tutorial

From the course: Visual Studio Developer Tips

IEnumerable Extension Methods

- [Instructor] I like to explore clever code and see how other developrs think about solving problems. This tip looks at a couple of C sharp extension methods that I find interesting. Both of these extension methods are targeted at lists of data. One extends I innumerable and the other extends I list. Now to see these methods, you need to open up this file. Innumerable extensions. And then I'll scroll down to the bottom of this editor for the first method. It's this one here called index range. It's used to get a range of items from a list, or a subset of items. It's a slight variation on the built-in get range method. Now, if you haven't seen extension methods, they are static methods that are inside a static class, and yet, C sharp and visual studio make it look like they're instant methods on an instance of the type, so the type that I'm extending in this case is this first parameter. An I list of T. See, it's a static method. It's extending I list of T, because of this keyword in…

Contents