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 { textBox1.Text = "abc"; int id = Convert.ToInt(textBox1.Text); } catch { // Somehow get the value for the parameter to the .ToInt method here }
textBox1.Text = "abc"; try { int id = Convert.ToInt(textBox1.Text); } catch(FormatException ex) { MessageBox.Show(textBox1.Text); }