public static void Main()
start: Console.WriteLine("Введите значение:");
var key = Console.ReadLine();
result = ParseToInt(key);
result = ParseToDouble(key);
Console.WriteLine("Не удалось распознать число!");
Console.WriteLine("Хотите ввести другое значение ? (Y/N)");
var answer = Console.ReadLine();
if(answer.ToLowerInvariant().Equals("y"))
Console.WriteLine("Программа завершена");
static void PrintMessage(object val)
Console.WriteLine(String.Format("Value {0} parsed to {1}", val, val.GetType()));
static bool ParseToInt(string key)
if(int.TryParse(key, out val))
static bool ParseToDouble(string key)
if(double.TryParse(key, out val))