C# provide a math function to calculate max of two numbers, This function have overloaded functions for long, int, float, decimal, short etc.
if you face any problem in finding the max value can use the below function.
C# Code to Find Maximum of Two Numbers :
using System;
namespace DemoConsoleApplication
{
class Max_of_Numbers
{
static void Main(string[] args)
{
Console.WriteLine(" Int Number Max: " + Math.Max(3,4));
Console.WriteLine(" Double Number Max: " + Math.Max(3.333, 4.444));
Console.WriteLine(" Long Number Max: " + Math.Max(3L, 4L));
Console.WriteLine(" Decimal Number Max: " + Math.Max(3.33M, 4.44M));
Console.ReadLine();
}
}
}
0 comments:
Post a Comment