CSharp - Write program to Get greater value with Math.MAX method


You will get the bigger value of two numbers using the built-in function Math.Max.


using System;
class Program/*from   w  ww. j  av  a  2s  .  c o m*/
    static void Main(string[] args)
        // Inputs 
        Console.Write("Enter first number: ");
        string input1 = Console.ReadLine();
        int number1 = Convert.ToInt32(input1);

        Console.Write("Enter second number: ");
        string input2 = Console.ReadLine();
        int number2 = Convert.ToInt32(input2);

        // Evaluating 
        int greater = Math.Max(number1, number2);

        // Output 
        Console.WriteLine("Greater of entered numbers is: " + greater);