[C#] 纯文本查看 复制代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ErrorTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int test;
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e) //button1点击事件
{
try
{
test = Convert.ToInt32(textBox1.Text); //因textBox1中没有字符,转换失败报错
}
catch (Exception ex)
{
Form2.reason = ex.ToString(); //错误原因
Form2 form2 = new Form2();
form2.ShowDialog(); //弹出Form2错误反馈
}
}
}
}