(I have tried finding a similar problem with no luck, so I am hoping maybe someone can provide a solution)
I have a do while loop in my first class with the goal of looping until the user inputs Feet, Meters or Yards as follows:
string convert = "";
do
{
Console.Clear();
Console.WriteLine("What conversion: Feet, Meters, Yards");
try
{
convert = Convert.ToString(Console.ReadLine());
}
catch (Exception)
{
Console.Clear();
Console.WriteLine("Incorrect conversion");
Console.ReadKey();
}
convert = Values.Input(convert);
Console.WriteLine(convert);
Console.ReadKey();
} while (_____); // Trying to loop while argument is thrown from my other class
Console.WriteLine("Continue on");
Console.ReadLine();
My separate values classes Input method:
public static string Input(string input)
{
string convert = input;
if (convert == "Meters")
{
input = "Meters";
}
else if (convert == "Feet")
{
input = "Feet";
}
else if (convert == "Yards")
{
input = "Yards";
}
else
{
throw new System.ArgumentException("Incorrect conversion");
//Trying to loop my main program if an ArgumentException is thrown here
}
return input;
}
What I've attempted:
} while (convert != "Meters" || convert != "Feet" || convert != "Yards");
Console.WriteLine("Continue on");
Console.ReadLine();
I've tried telling it to keep looping while convert is not Meters, Feet or Yards, but after the argument is thrown I am unable to continue the program.
Would I be able to continue my application after throwing this System.ArgumentException
and if so what would I input into my while loop to allow this?