Declare MAX before you start the while loop. The way you have it you can only access within the while.
Double MAX = 0;
while (Condition)
{
MAX = somecode.....
.....
}
Console.WriteLine("The OPTIMAL Value : " + MAX);