Advertisement
OldBeliver

Function_03ver04

Mar 27th, 2021
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ReadInt_04
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int number = 0;
  14.  
  15.             ReadInt(ref number);
  16.  
  17.             Console.Write($"Возвращение сконвертированного числа через out number: ");
  18.             Console.WriteLine(number);
  19.         }
  20.  
  21.         static void ReadInt(ref int number)
  22.         {
  23.             bool exit = false;
  24.  
  25.             while (exit == false)
  26.             {
  27.                 Console.Write($"Введите число: ");
  28.                 bool result = int.TryParse(Console.ReadLine(), out number);
  29.  
  30.                 if (result)
  31.                 {
  32.                     exit = true;
  33.                 }
  34.                 else
  35.                 {
  36.                     Console.WriteLine($"это не число");
  37.                 }
  38.             }
  39.         }
  40.     }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement