public static int ReadInt(string prompt, List <Option> options) { Output.DisplayPrompt(prompt); string input = Console.ReadLine(); if (input == "") { for (var i = 0; i < options.Count; i++) { if (options[i].Name == go_back_menu) { return(i + 1); } } } int value; while (!int.TryParse(input, out value) || ((value < 1) || (value > options.Count))) { Output.DisplayPrompt("Please enter an integer from 1 to " + options.Count); input = Console.ReadLine(); } return(value); }
public static string ReadString(string prompt) { Output.DisplayPrompt(prompt); var input = ReadLine(); return(input); }
public static int ReadInt(int min, int max) { int value = ReadInt(); while (value < min || value > max) { Output.DisplayPrompt("Please enter an integer between {0} and {1} (inclusive)", min, max); value = ReadInt(); } return(value); }
public static DateTime ReadDate(string prompt, DateTime min, DateTime max) { DateTime value = ReadDate(prompt); while (value < min || value > max) { Output.DisplayPrompt("Please enter a date between {0} and {1} (inclusive)", min, max); value = ReadDate(prompt); } return(value); }
public static double ReadDouble(string prompt, float min, float max) { double value = ReadDouble(prompt); while (value < min || value > max) { Output.DisplayPrompt("Please enter a numeric value between {0} and {1} (inclusive)", min, max); value = ReadDouble(prompt); } return(value); }
public static int ReadInt() { string input = ReadLine(); int value; while (!int.TryParse(input, out value)) { Output.DisplayPrompt("Please enter an integer"); input = ReadLine(); } return(value); }
public static int ReadInt(int min, int max) { int value = ReadInt(); while (value < min || value > max) { Output.DisplayPrompt("Por favor digite um inteiro entre {0} e {1} (inclusive)", min, max); value = ReadInt(); } return(value); }
public static double ReadDouble(string prompt) { Output.DisplayPrompt(prompt); string input = ReadLine(); double value; while (!double.TryParse(input, out value)) { Output.DisplayPrompt("Please enter a numeric value"); input = ReadLine(); } return(value); }
public static DateTime ReadDate(string prompt) { Output.DisplayPrompt(prompt); string input = ReadLine(); DateTime value; while (!DateTime.TryParse(input, out value)) { Output.DisplayPrompt("Please enter a valid date-time"); input = ReadLine(); } return(value); }
public static int ReadInt() { string input = Console.ReadLine(); int value; while (!int.TryParse(input, out value)) { Output.DisplayPrompt("Por favor insira um inteiro"); input = Console.ReadLine(); } return(value); }
public static string ReadString(string prompt) { Output.DisplayPrompt(prompt); return(Console.ReadLine()); }
public static int ReadInt(string prompt, int min, int max) { Output.DisplayPrompt(prompt); return(ReadInt(min, max)); }
public static ConsoleKeyInfo ReadKey(string prompt) { Output.DisplayPrompt(prompt); return(Console.ReadKey()); }