Reader small image

You're reading from  Learning C# by Developing Games with Unity - Seventh Edition

Product typeBook
Published inNov 2022
Reading LevelBeginner
PublisherPackt
ISBN-139781837636877
Edition7th Edition
Languages
Tools
Right arrow
Author (1)
Harrison Ferrone
Harrison Ferrone
author image
Harrison Ferrone

Harrison Ferrone is an instructional content creator for LinkedIn Learning and Pluralsight, tech editor for the Ray Wenderlich website, and used to write technical documentation on the Mixed Reality team at Microsoft. He is a graduate of the University of Colorado at Boulder and Columbia College, Chicago. After a few years as an iOS developer at small start-ups, and one Fortune 500 company, he fell into a teaching career and never looked back.
Read more about Harrison Ferrone

Right arrow

Querying data with LINQ

We’ve covered a few different ways to store elements, or sequences of values, in this chapter—the one thing we haven’t talked about is how to get specific subsets of data back out. So far, our game’s loot is stored in a Stack variable, and we can always pop off the next loot element in the order they are stored, but that doesn’t help us when we want to filter down the stack (or any other collection type we’ve discussed in this book) to specific elements that fit predefined criteria.

For example, say we wanted to get a list of all the elements in the Loot stack with a rarity value of 3 or more. We could absolutely use a looping statement, but that leads to a lot of code and manual checks if we wanted to add more parameters to our filter. Instead, C# has a specific set of features for querying data called LINQ, which stands for Language Integrated Query. LINQ is fast, efficient, and, most importantly, customizable...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Learning C# by Developing Games with Unity - Seventh Edition
Published in: Nov 2022Publisher: PacktISBN-13: 9781837636877

Author (1)

author image
Harrison Ferrone

Harrison Ferrone is an instructional content creator for LinkedIn Learning and Pluralsight, tech editor for the Ray Wenderlich website, and used to write technical documentation on the Mixed Reality team at Microsoft. He is a graduate of the University of Colorado at Boulder and Columbia College, Chicago. After a few years as an iOS developer at small start-ups, and one Fortune 500 company, he fell into a teaching career and never looked back.
Read more about Harrison Ferrone