Using C# LINQ - A Practical Overview
player_one
1637.9K views
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.
Which category best describes the Count() method?
Which category best describes the Intersect() method?
Which category best describes the SelectMany() method?
Which category best describes the ElementAt() method?
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.