.Min()
The Math.Min()
method returns the lesser of two specified numbers.
Syntax
Math.Min(num1, num2)
Math.Min()
returns the lesser value from num1
and num2
.
Example
The following example compares two integers i1
and i2
and writes the lesser integer to the console.
using System;public class Example {public static void Main (string[] args) {int i1 = -134, i2 = 268;Console.WriteLine("Math.Min (int) = " + Math.Min(i1,i2));}}
This example results in the following output:
Math.Min (int) = -134
Codebyte Example
Try changing the values of xint1 and xint2 to see the results.
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.