Created
May 11, 2025 09:21
-
-
Save Strelok78/756fee08ebf0e7a2dcbcd848347215c2 to your computer and use it in GitHub Desktop.
Read Int
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace iJuniorPractice | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Console.WriteLine(ReadInt()); | |
} | |
static int ReadInt() | |
{ | |
string input; | |
int result; | |
Console.WriteLine("Enter your number: "); | |
input = Console.ReadLine(); | |
while (int.TryParse(input, out result) == false) | |
{ | |
Console.WriteLine("Incorrect input, enter number..."); | |
input = Console.ReadLine(); | |
} | |
return result; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment