LINQ: Searching in Program Pt.2- C# Skill in Unity: 14

S.J. Jason Liu
3 min readOct 8, 2021

--

Objective: continue digging more extension of LINQ.

Let’s continue from the last tutorial with more extensions of LINQ.

Where

“Where” can be used to find out datas with specific rule or condition.
Let’s use “Where” to list out the grades that greater than 60.

Using “Where” with lambda to grab the data from a condition, and store it within a variable.

It should list out all the qualified.

Order by descending & reverse

This one would be handy when you need to sorting the datas in order.
Let’s use the grades in the last example code, we can sorting them in the order of descending.

It would print out all grades in descending order.

And how to make the datas sorting in ascending? We can simply add “Reverse()” in the end of “OrderByDescending”.

Sum & average

The last and convenient to use is sum and average.
Sum and average is quite easy to understand, which would only be careful about the type of datas.
When using sum or average, if the datas are all integer type, you can leave it as blank in brackets.

That would be all of introducing LINQ of Unity in these 2 tutorials. You can always check the documentation of LINQ from Microsoft to find out more ways of using it.

--

--

S.J. Jason Liu
S.J. Jason Liu

Written by S.J. Jason Liu

A passionate gamer whose goal is to work in video game development.

No responses yet