Open In App

LINQ | Filtering Operator | OfType

Filtering operators are those operators which are used to filter the data according to the user requirement from the given data source or from the given sequence. For example, in an employee record, we want to get the data of the employees whose age in 21. So, we filter the record, according to their age. In LINQ, you can filter using the following operators:

  1. Where
  2. OfType

OfType Operator

OfType operator filters the sequence or data source depends upon their ability to cast an element in a collection to a specified type. It is implemented by using deferred execution, means it immediately returns an object which contains the information that is required to perform the action, but executes when the object is iterate over the loop by using foreach loop or for loop.




Article Tags :
C#