Hey guys, Im making a calculator in C# console app, how do I ONLY allow Numbers? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Hey guys, Im making a calculator in C# console app, how do I ONLY allow Numbers?

Calculator C#

10th Dec 2020, 1:20 AM
Henrique
Henrique - avatar
4 Answers
+ 1
Maybe, converting might show an error if the input is string. It wont be able to convert string to int. So maybe use a try exept
10th Dec 2020, 2:58 AM
Steve Sajeev
Steve Sajeev - avatar
+ 1
Henrique Use Convert.ToInt32()
10th Dec 2020, 2:37 AM
A͢J
A͢J - avatar
0
try TryParse() in while/do-while
10th Dec 2020, 1:47 AM
Flash
0
Thanks
10th Dec 2020, 7:46 AM
Henrique
Henrique - avatar