The program first asks the user for the number of elements to be stored in the array, then asks for the numbers. This is my code
static void Main
This code will help you in very simple way without adding any loops and conditions
int[] arr={1,1,2,4,5,1,2,1}; Array.Sort(arr); Console.WriteLine("Min no: "+arr[0]); Console.WriteLine("Max no: "+arr[arr.Length-1]);