Smaller of two values
Compare two values and return the smaller one.
Math.Min
Simple example
Start3 · 7
Result3
using System;
Console.WriteLine(Math.Min(3, 7));
3
Advertisements
Everyday examples
Two buses charge 8 and 5 for the same trip. Which fare is cheaper?
Start8 · 5
Result5
using System;
Console.WriteLine(Math.Min(8, 5));
5
A child wants 5 stickers. You have 3 left. How many can you give them?
Start5 · 3
Result3
using System;
Console.WriteLine(Math.Min(5, 3));
3
Two walks to school take 12 and 9 minutes. How long is the quicker walk?
Start12 · 9
Result9
using System;
Console.WriteLine(Math.Min(12, 9));
9
If both values are equal, the answer is that same value.
Run the example
dotnet new console --output Lesson
cp Program.cs Lesson/Program.cs
dotnet run --project Lesson