In this example we are finding out the maximum values from an int array with Max() Method.
Source code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
static void Main(string[] args) { Console.Write("\n \n *** www.csharp-console-examples.com \n \n"); int[] numbers = { 5, 36, 23, 45, 15, 92, -5, 3, 33 }; int max = numbers.Max(); foreach(int num in numbers) { Console.Write(num+" "); } Console.WriteLine(); Console.WriteLine("================================="); Console.WriteLine("Max Value in Array :"+max); Console.ReadKey(); } |
Output:
You can find more similar examples of programming for this programming language in the site.