You can loop through the array to get the maximum value and you only need to retain the largest value found thus far, so:
int max = Int32.MinValue;
for (var i = 0; i < array.Length; i++)
{
if (array[i] > max) {
max = array[i];
}
}
Console.WriteLine(max);
You can also use .Max()
and that does this in the background.
solved Get largest element in array in C# [duplicate]