# c# programming : How to find largest number in given two number

You can easily find largest number between two number using Max, which is static method of Math class. This method is overload with multiple data types, such as Max(Byte, Byte) , Max(Decimal, Decimal) and many more data types. Here we take an example with integer number.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

int a = -3, b = 52;

Decimal deci = -4, deci1 = 53;

Console.WriteLine(" the maximum number in between a= {0} and b={1} are {2}",a,b, Math.Max(a, b));

Console.WriteLine(" the maximum number in between a= {0} and b={1} are {2}", deci, deci1, Math.Max(deci, deci1));

Console.ReadKey();

}

}

}

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

int a = -3, b = 52;

Decimal deci = -4, deci1 = 53;

Console.WriteLine(" the maximum number in between a= {0} and b={1} are {2}",a,b, Math.Max(a, b));

Console.WriteLine(" the maximum number in between a= {0} and b={1} are {2}", deci, deci1, Math.Max(deci, deci1));

Console.ReadKey();

}

}

}

I am very thankful to provide us really very ifnoramive post us. i love your trick on how to find largest . this is really good programming .Programmierung

ReplyDelete