advertise with us

C# – LINQ Select Examples

Select is a LINQ functionality to define a data format of the query results.

Each of below examples is presented in C# with both Lambda and Query expression.

Let’s create a Person class.

And collection of people which we query with LINQ expressions.

1. Select single value

Query collection to get forenames only.

Lambda expression:

Query expression:

Print to screen:

Result:

2. Select anonymous type

Query collection to get anonymous type objects containing surname and year of birth.

Lambda expression:

Query expression:

Print to screen:

Result:

3. Select existing type

Query collection to get Person objects with upper-cased forenames and surnames.

Lambda expression:

Query expression:

Print to screen:

Result:


Need Help with Your C# Projects?

We offer expert support and development services for projects of any size. Contact us for a free consultation and see how we can help you succeed.

CONTACT US NOW