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 PostThe easiest solution is not necessarily the best solution. When writing programs you have to consider the "stupid users" factor by making your program as non-breakable as possible. Murphy's Law -- if anythihng can go wrong, it will. Don't expect averyone to enter perfect data -- when testing your program …
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.