public static void main(string[] args)
output("Enter a number greater than 50 but less than or equal to 100: " + "\n");
num = (int) inputValue();
while (num < 51 || num > 100)
output("The number is not within the required range -- please enter a valid number: " + "\n");
num = (int) inputValue();
output("Congratulations." + "\n");
' .NET can only read single characters or entire lines from the console.
' The following functions are designed to help input specific data types.
private static double inputValue()
while (!double.TryParse(Console.ReadLine(), out result));
private static string inputText()
return Console.ReadLine()
private static output(string text)