using System;
using System.Linq;
namespace MainPrograms
{
class Program
{
static void Main(string[] args)
{
// Declare and initialize the integer array
int[] NumbersArray = { 102, 34, 89, 12, 187, 29, 111 };
// Sort the array, the first element in the array will be
// smallest and the last element will be largest
Array.Sort(NumbersArray);
// Print the smallest number in the array
Console.WriteLine("Smallest Number = {0}", NumbersArray[0]);
// Print the largest number in the array.
Console.WriteLine("Largest Number = {0}",
NumbersArray[NumbersArray.Length-1]);
//will taking any character for vanishing console
Console.ReadKey();
// Linq makes this much easier, as we have Min() and Max() extension methods
// Console.WriteLine("Samllest Number = {0}", NumbersArray.Min());
// Console.WriteLine("Largest Number = {0}", NumbersArray.Max());
}
}
}
No comments:
Post a Comment