111,129
社区成员
发帖
与我相关
我的任务
分享namespace _2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
int div = int.Parse(textBox1.Text) / int.Parse(textBox2.Text);
textBox3.Text = div.ToString();
}
}
}
if(int.Parse(textBox2.Text.Trim()))
throw new DivideByZeroException("除数不能为0");
if(textBox2.Text.Trim()=="0")
throw new DivideByZeroException("除数不能为0");
str=textbox2.text.trim();
if(str="0" || int.parse(textbox2.text)==0)
string str;
private void button1_Click(object sender, EventArgs e)
{
str=textbox2.text.trim()
if(str="0" or int.parse(textbox2.text)==0)
Messagebox.show("除数不能为0!","Error");
else
int div=int.parse(textbox1.text)/int.parse(textbox2.text);
textbox3.text =div.tostring();
}
private void button1_Click(object sender, EventArgs e)
{
try{
int div = int.Parse(textBox1.Text) / int.Parse(textBox2.Text);
textBox3.Text = div.ToString();
}
catch(DivideByZeroException ex)
{
MessageBox.Show("不能除以0");
}
}
private void button1_Click(object sender, EventArgs e)
{
try()
{
int div = int.Parse(textBox1.Text) / int.Parse(textBox2.Text);
textBox3.Text = div.ToString();
if (int.Parse(textBox2.Text) == 0)
}
catch(DivideByZeroException ex)
{
MessageBox.Show("不能除以0");
}
catch(Exception e)
{
MessageBox.Show("除以0异常");
};
}

namespace _2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
int div = int.Parse(textBox1.Text) / int.Parse(textBox2.Text);
textBox3.Text = div.ToString();
try(DivideByZeroException e)
{
if (int.Parse(textBox2.Text) == 0)
}
catch(Exception e)
{
MessageBox.Show("除以0异常");
};
}
}
}