how can I find the Min and Max with a for loop

hi I have problem in my code I'm trying to find the minimum height of a plant and the max height of the plant with a for loop but I'm running into a problem and I cant solve it (this in C# BTW) the code:

int i;
double height, min, max;
Console.WriteLine("Insert the height of plant");
height = double.Parse(Console.ReadLine());
min = 0;
max = 0;
for (i = 1; i <= 9; i++)
{
    height = double.Parse(Console.ReadLine());
    if(height >= max)
    {
        height = max;
    }
    if(height < max)
    {
        height = min;
    }
}
Console.WriteLine("Maximum hight = {0}", max);
Console.WriteLine("Minimum hight = {0}", min);

Adjust your starting min and max to be the same as the initial input. Then, as you loop, compare those to see if the values are larger or smaller than the current min/max:

double height, min, max;
Console.WriteLine("Insert the height of plant");
height = double.Parse(Console.ReadLine());
min = height;
max = height;

for (int i = 1; i <= 9; i++)
{
    height = double.Parse(Console.ReadLine());

    if (height > max)
        max = height;
    if (height < min)
        min = height;
}
Console.WriteLine("Maximum hight = {0}", max);
Console.WriteLine("Minimum hight = {0}", min);

As suggested by Dmitry, you can even reduce your for loop to this to simply return the smaller/larger number into min/max:

for (int i = 1; i <= 9; i++)
{
    height = double.Parse(Console.ReadLine());

    max = Math.Max(max, height);
    min = Math.Min(min, height);
}