.Max()
The Math.Max()
method returns the greater of two specified numbers.
Syntax
Math.Max(num1, num2)
Math.Max()
returns the greater value from num1
and num2
.
Example
The following example compares two integers i1
and i2
and writes the greater integer to the console.
using System;public class Example {public static void Main (string[] args) {int i1 = -234, i2 = 345;Console.WriteLine("Math.Max (int) = " + Math.Max(i1,i2));}}
This example results in the following output:
Math.Max (int) = 345
Codebyte Example
The following example is runnable and uses the Math.Max()
method to return the greater number from the given two integer
type numbers, number1
and number2
:
All contributors
- cslylla54 total contributions
- StevenSwiniarski466 total contributions
- Anonymous contributorAnonymous contributor1 total contribution
- cslylla
- StevenSwiniarski
- Anonymous contributor
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.