Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find minimum values among the 5 integers?

Tags:

c#-4.0

I need to find the minimum of 5 integer values. i have used if else statement to compare. So its not looking good. i.e. code is very lengthy. I dont know how to reduce the code complexity. can anyone help me out?

Regards, Karthi

like image 552
Karthi Avatar asked Sep 29 '12 08:09

Karthi


People also ask

How do you find the minimum number in Python?

Use Python's min() and max() to find smallest and largest values in your data.


2 Answers

You can use Min method from LINQ:

var list = new[] {1, 2, 3, 4, 5};
int min = list.Min();

Here is the list of LINQ Min you can refer:

http://msdn.microsoft.com/en-us/library/system.linq.enumerable.min.aspx

like image 133
cuongle Avatar answered Sep 22 '22 04:09

cuongle


Check out the Min method of LINQ.

like image 33
Golo Roden Avatar answered Sep 25 '22 04:09

Golo Roden