Advertisement
RamGaal

Homework 4 ex.3

May 22nd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. using System;
  2. class MainClass
  3. {
  4.     public static void Main(string[] args)
  5.     {
  6.         int chislo = 0;
  7.  
  8.         VvodChisla(ref chislo);
  9.         Console.WriteLine("Вы ввели число: " + chislo);
  10.         Console.ReadKey();
  11.     }
  12.  
  13.     public static int VvodChisla(ref int chislo)
  14.     {
  15.         while(true)
  16.         {
  17.             Console.Write("Введите число: ");
  18.             bool preobrazovane = int.TryParse(Console.ReadLine(), out chislo);
  19.             Console.Clear();
  20.             if (preobrazovane)
  21.             {
  22.                 return chislo;
  23.             }
  24.             else
  25.             {
  26.                 Console.WriteLine("Вы ввели что-то не то!");
  27.             }
  28.         }              
  29.     }      
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement