Using C# LINQ - A Practical Overview
Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
LINQ Concepts - Using LINQ
LINQ is a collection of extension methods that extend the IEnumerable<T>
interface, as discussed in the Background lessons. There are around 50 unique methods currently available in LINQ (even more if you count different signature variations as separate methods)! The complete list can be found here:
MSDN Enumerable Methods documentation
Some methods are very simple, such as the Count()
method. On the other hand, several LINQ methods are very complicated and difficult to understand. The GroupJoin()
method would be a good example of this.
General method categories
- Some methods return a single element from the target sequence, such as
First()
orLast()
. - Some methods return multiple elements out of the target sequence, such as
Take()
,Skip()
, andWhere()
. - Some methods return the entire target sequence with the elements' order changed, such as
Reverse()
andOrderBy()
. - Some methods return a single calculated value based on the input, such as
Any()
,Sum()
, andMax()
. - Some methods return a completely different sequence based on the target sequence, such as
Select()
andCast()
.
Categorization quiz
Based on the method name and the signature information in the MSDN documentation, try to guess in which of the above categories each method belongs.