From the course: .NET Essentials: Working with LINQ

Unlock this course with a free trial

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

Explore the OfType class definitions

Explore the OfType class definitions - .NET Tutorial

From the course: .NET Essentials: Working with LINQ

Explore the OfType class definitions

- The where clause allows us to filter a sequence based on a predicate function. What we'll look at in this video and in the next video, is another extension method called 'Of Type'. It allows us to filter a sequence based on the type of the items that are in the sequence. I think a good place to start is to look at the classes I've defined in Visual Studio and their class relationships. So we are over in Visual Studio looking at CourseLib, this library, and I'm looking at this CardsDiagram.cd. This represents a card trading application. So I have a base class called Card, that has some properties like Asking Price and the Description and the name of the card. And then I've got two derive types. The Creature type and the Robot type, and they have their own additional properties. Below that we have some more derived types, Monster is a creature, Cyborg, Android are both robots. You'll notice that the Robot class implements IC…

Contents