LINQ: Searching in Program Pt.1- C# Skill in Unity: 13

Objective: quick introduction of LINQ of Unity.

LINQ: Language Integrated Query- which is used to searching in program data. Using LINQ well will help you organizing database quicker and properer. Here are some properties to use LINQ.


When searching a specific data in array or list, we might need to create a foreach loop to look up the data. Using “any” would return the result of searching as value bool. But before we using LINQ, we must contain namespace “System.Linq”.

Let’s use foreach loop to create some code that we can use “Any” to improve.

Any” would tell if there is any result matched to request, and we need to use lambda to search in the database.

And we can store the result in a variable to print out.

And the result would be quite obviously.


Contains is pretty much the same as “any” but easier.

And the result would be the same.


The situation of using Distinct is quite different. It would remove the duplicated and restore the list or array as a new one. Which would be handy to remove some duplicated data.

We will run “distinct” with new array data with some duplicated one.

Using “distinct”, you will not need any parameter.

And the result would ignore the duplicated data to print out the distinct.




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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

HackTheBox: Bashed Walkthrough

Monthly SolydRecap — March 2020

Auto data scrapping with no code 🕷

Tellor community call November 2nd 2021

Track Available COVID-19 Vaccine Slots in India with Python

Algebraic Structure and Protocols

Exilon announces referral program

Trustlessness, Erlang and the Blockchain Revolution: An Interview with Robert Virding

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
S.J. Jason Liu

S.J. Jason Liu

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

More from Medium

How to use Post Processing in Unity

Delegate, Event, and Action

Custom Dynamic Ambient Systems

Creating An Advanced 2D Player Controller Without Any Unity Components! (Part 2)