-1
我想在我的程序中添加異常處理,以便在消息框中顯示給用戶。 「輸入的格式不正確,請輸入數值」以獲取我的產品價格值。目前,當我輸入錯誤的格式,如字符串值時,我收到一條錯誤消息,指出未處理的異常輸入字符串的格式不正確。而不是我想要一個消息框出現。任何人都可以將我指向正確的方向。謝謝。下面的代碼我用在我的程序中。未處理的異常輸入字符串格式不正確
if (result == System.Windows.Forms.DialogResult.Yes)
{
// update the employee record
((Employee)o).ProductName = this.textProdName.Text;
((Employee)o).ProductPrice = Convert.ToDouble(this.textProdPrice.Text);
((Employee)o).ProductId = this.textProdID.Text;
((Employee)o).ProductQuantity = Convert.ToInt32(this.textProdQuantity.Text);
MessageBox.Show(((Employee)o).ProdName + " record has been updated with new details, except the ID.");
我的眼睛真的很疼.... !!請格式化代碼.. [C#基礎教程,異常處理](http://www.tutorialspoint.com/csharp/csharp_exception_handling.htm) – MethodMan 2014-12-04 21:48:06