C# LINQ — “Min”/“Max”

LINQ (Language-Integrated Query) is a set of integrated C# capabilities which allow queries against data.

Today’s Objective: Demonstrate the Min and Max methods of LINQ to get the minimum and maximum numerical values from a data collection.

The Min/Max Methods:

Simple C# LINQ methods used to identify the lowest and highest numerical values in a data collection.

Microsoft Documentation for “Min” / Microsoft Documentation for “Max”

An Example:

Without LINQ, you may use code similar to this to find the minimum or maximum value:

But by using LINQ, you can simply write:

Like most LINQ methods, it also works for custom data types that are not numeric, but contain numeric variables:

--

--

--

Unity game developer / C# Programmer / Gamer. Australian (Tasmanian) indie games developer for 10+ years. Currently looking for games industry employment.

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

Recommended from Medium

Go, Git it! — Beginner’s guide to making your first commit.

How to Compile C Program in Command Prompt

Go Serverless Series: Break down Serverless Framework into Steps

Opinion about Raspberry pi 4 as a Frontend Developer

Raspberry pi 4

Google Cardboard 360 Viewer Tutorial

The 10 Best C# Books to Help You Learn or Improve Your Skills 📚

DartLang Fundamentals #1

Throwback — Part 7 — THROWBACK-DC01, CORP-DC01, CORP-ADT01

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
Vincent Taylor

Vincent Taylor

Unity game developer / C# Programmer / Gamer. Australian (Tasmanian) indie games developer for 10+ years. Currently looking for games industry employment.

More from Medium

What Is C# LINQ?

Find the first date of a week from a given date In C#

Encapsulation in C#

C# — switch expression ; switch statement — Whats comming on?