Anonim_999

Untitled

Mar 6th, 2021
672
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace ConsoleApp1
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int numberUser = CountNumber();
  10.             Console.WriteLine($"Возвращенное число: {numberUser}");
  11.         }
  12.  
  13.         private static int CountNumber()
  14.         {
  15.             int number;
  16.             bool isContinue = true;
  17.  
  18.             while (isContinue)
  19.             {
  20.                 Console.Write("Введите число: ");
  21.                 string userInput = Console.ReadLine();
  22.                 bool success = Int32.TryParse(userInput, out number);
  23.  
  24.                 if (!success)
  25.                 {
  26.                     Console.WriteLine($"Попытка преобразования '{userInput}' неудачна.");
  27.                 }
  28.             }
  29.             return number;
  30.         }
  31.     }
  32. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×