Declaring a Query and Filtering by Type
Explore how to declare LINQ queries with either the var keyword or specific types to improve code clarity. Understand how to filter collections by type using the OfType extension method. This lesson helps you manage complex type hierarchies in sequences and refine data queries for better control and readability.
We'll cover the following...
We'll cover the following...
Declaring a query using var or a specified type
While writing a LINQ expression, it is convenient to use var to declare the query object. This is because the type frequently changes as we work on the LINQ expression. For example, our query started as an IEnumerable<string> and is currently an ...