Console.WriteLine("insert The Number::");
int c = Convert.ToInt32( Console.ReadLine());
Saqlainz
-1
Newbie Poster
Recommended Answers
Jump to PostWhile easy, that will throw an unhandled exceptioon error if the input string can't be converted to an integer. Using the int.TryParse something like this:
Console.WriteLine("insert The Number::"); int c = 0; while (!int.TryParse(Console.ReadLine(), out c)) { Console.WriteLine("Invalid input"); }
will make your code much …
Jump to Postwell this is also a way but i told the easiest of all
Using an easy solution that is also easy to break is a good way to make yourself go bald faster.
Whereas using an easy solution that is hard to break is much more useful.
All 8 Replies
tinstaafl
1,176
Posting Maven
Saqlainz
commented:
well this is also a way but i told the easiest of all
+0
tinstaafl
1,176
Posting Maven
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Saqlainz
-1
Newbie Poster
ddanbe
2,724
Professional Procrastinator
Featured Poster
Saqlainz
-1
Newbie Poster
Mike Askew
commented:
See post below.
-1
ddanbe
2,724
Professional Procrastinator
Featured Poster
Mike Askew
131
Veteran Poster
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.