public static void Main()
int [] array = new int [] {1, 23, 12, 9, 30, 2, 50};
int array_length = array.Length;
Console.WriteLine("Maximum array length is "+ array_length + "\nEnter number of items to display: ");
int k = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Numer of items to list is greater than array length");
Console.WriteLine("First " + k + " smallest items in ascending order are :");
for (int i = 0; i<=k-1;i++) {
Console.WriteLine(array[i]);
Console.WriteLine("First " + k + " largest items in descending order are :");
for (int i = 0; i<=k-1;i++) {
Console.WriteLine(array[i]);