Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我得到了这个例外
FormatException 未处理,输入字符串的格式不正确。
在以下声明中
int amnt = int.Parse(Console.ReadLine());
我应该怎么做才能解决它?
我建议如下:
int parsedInt = 0; if (int.TryParse(Console.ReadLine(), out parsedInt)) { //do success work } else { //do failed work }