I am trying to return the Max value from asking a user to input a first and second value. I am also trying to utilize the Math.Max function.
class Return_Values
{
public void RunExercise()
{
Console.WriteLine("First value?");
int firstNumber = Int32.Parse(Console.ReadLine());
Console.WriteLine("Second value?");
int secondNumber = Int32.Parse(Console.ReadLine());
int theMax;
Max m = new Max();
m.returnMax(firstNumber, secondNumber);
Console.WriteLine("The max of {0} and {1} is {2}", firstNumber, secondNumber, theMax);
}
}
class Max
{
public int returnMax(int firstNumber, int secondNumber)
{
int theMax = Math.Max(firstNumber, secondNumber);
return theMax;
}
}
I keep getting the error, Use of unassigned local variable 'theMax'.