Skip to content

Instantly share code, notes, and snippets.

@miteshsureja
Created May 21, 2017 13:04
Show Gist options
  • Save miteshsureja/fe0e8923c9a4fc5f774be20ed70ba7a8 to your computer and use it in GitHub Desktop.
Save miteshsureja/fe0e8923c9a4fc5f774be20ed70ba7a8 to your computer and use it in GitHub Desktop.
Find Max and Min value from List
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RandomNumbers
{
class Program
{
static void Main(string[] args)
{
List<int> myList = new List<int>() { 12, 4, 32, 8, 9, 20 , 5, 56, 76, 98};
int max = myList[0], min = myList[0];
for (int i = 0; i < myList.Count; i++)
{
if (myList[i] > max)
max = myList[i];
if (myList[i] < min)
min = myList[i];
}
Console.WriteLine("Max - {0}", max);
Console.WriteLine("Min - {0}", min);
Console.Read();
}
}
}
@miteshsureja
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment