- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
MathF.Max() Method in C# with Examples
The MathF.Max() method in C# returns the larger of the two specified numbers.
Syntax
Following is the syntax −
public static float Max (float val1, float val2);
Above, val1 is the first number, whereas val2 is the second number. Both of these numbers are compared.
Example
Let us now see an example to implement the MathF.Max() method −
using System; public class Demo { public static void Main(){ float val1 = 11.89f; float val2 = 55.67f; Console.WriteLine("Maximum Value = "+MathF.Max(val1, val2)); } }
Output
This will produce the following output −
Maximum Value = 55.67
Example
Let us now see another example to implement the MathF.Max() method −
using System; public class Demo { public static void Main(){ float val1 = 1.00f; float val2 = 0.11f; Console.WriteLine("Maximum Value = "+MathF.Max(val1, val2)); } }
Output
This will produce the following output −
Maximum Value = 1
Advertisements