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.
如果发生意外错误,我想让我的表单保持在空闲模式,让我的程序获取输入。一旦用户输入错误的输入,我有一个 try and catch 块来捕获错误的用户输入。我想弹出消息并停止该过程,直到用户输入正确的输入。我的应用程序正在接收弹出消息,但不会停止并继续下一个进程。
尝试这个:
bool inputCorrect = false; while (!inputCorrect) { try { //Try some code inputCorrect = true; } catch (Exception e) { //MessageBox.Show("Wrong entery...Please correct!!") } }