lovelyvook

Unit_27

Jun 28th, 2024 (edited)
698
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Ijunior
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Console.WriteLine("Преобразованное число: " + GetNumber());
  10.         }
  11.  
  12.         static int GetNumber()
  13.         {
  14.             int number = 0;
  15.             string userInput = "";
  16.  
  17.             while (!int.TryParse(userInput, out number))
  18.             {
  19.                 Console.Write("Введите число: ");
  20.                 userInput = Console.ReadLine();
  21.             }
  22.  
  23.             return number;
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment