Hello all,
I've been looking at various c# timing functions but can't seem to find the right one. The closest one I seem to have found is stopwatch function, that only measures the time it takes to complete a command. What i'm after is a stopwatch function that only measures the time it takes for a user to input a value.
for example:
op1:
answer = num1 + num2;
Console.WriteLine("Number 1: " + (num1));
Console.WriteLine("Number 2: " + (num2));
Console.WriteLine("Answer: " + (answer));
Console.WriteLine();
op1r:
Console.WriteLine("What is the Answer?");
Console.WriteLine();
Console.WriteLine("1 - Add");
Console.WriteLine("2 - Subtract");
Console.WriteLine("3 - Multiply");
Console.WriteLine("4 - Divide");
input = Console.ReadLine();
intInput = int.Parse(input);
#region
if (intInput == 1)
{
Console.WriteLine("Correct! Well Done!");
Console.ReadLine();
goto start;
}
else if (intInput >= 2)
{
Console.WriteLine("Sorry you are incorrect!");
Console.ReadLine();
}
else if (intInput >= 5)
{
Console.WriteLine("Please enter a number between 1 - 4 only!");
goto op1r;
}
#endregion
I want the stopwatch function to start as soon as the beginning of that code is called, and then i only want it to stop when the user has entered the correct number.
Any help to point me in the right direction would be greatly appreciated.
P.s Sorry if the code is messy.