Newbie Question on C#

Can someone explain to me clearly why the output I get is 4, -7, -99? Just want to understand why the output is that ive tried to figure it out but it seems im not getting anywhere.. Sorry but Im still learning xD Heres the code. Thanks!

class Program { static void Main(string[] args) { int[] array = new int[] { 4, 51, -7, 13, -99, 15, -8, 45, 90 }; int currentMinimum = Int32.MaxValue; for (int index = 0; index < array.Length; index++) { if (array [index] < currentMinimum) { currentMinimum = array[index]; Console.WriteLine(currentMinimum); } } Console.ReadKey(); } } 

by Snifffey via /r/csharp

Leave a Reply