首页上一页 1 下一页尾页 1 条记录 1/1页
为什么出错
发表在C#图书答疑
2013-09-13
是否精华
是
否
版块置顶:
是
否
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
partial class account
{
public int addition(int a, int b)
{
return a + b;
}
}
partial class account
{
public int multiplication(int a, int b)
{
return a * b;
}
}
partial class account
{
public int subtraction(int a, int b)
{
return a - b;
}
}
partial class account
{
public int division(int a, int b)
{
return a / b;
}
}
private void Form1_Load(object sender, EventArgs e)
{
comboBox1.SelectedIndex = 0;为什么这个地方调试时会出错
comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
}
private void button1_Click(object sender, EventArgs e)
{
try
{
account at = new account();
int M = int.Parse(textBox1.Text.Trim());
int N = int.Parse(textBox2.Text.Trim());
string str = comboBox1.Text;
switch (str)
{
case "加": textBox3.Text = at.addition(M, N).ToString(); break;
case "减": textBox3.Text = at.subtraction(M, N).ToString(); break;
case "乘": textBox3.Text = at.multiplication(M, N).ToString(); break;
case "除": textBox3.Text = at.division(M, N).ToString(); break;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
partial class account
{
public int addition(int a, int b)
{
return a + b;
}
}
partial class account
{
public int multiplication(int a, int b)
{
return a * b;
}
}
partial class account
{
public int subtraction(int a, int b)
{
return a - b;
}
}
partial class account
{
public int division(int a, int b)
{
return a / b;
}
}
private void Form1_Load(object sender, EventArgs e)
{
comboBox1.SelectedIndex = 0;为什么这个地方调试时会出错
comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
}
private void button1_Click(object sender, EventArgs e)
{
try
{
account at = new account();
int M = int.Parse(textBox1.Text.Trim());
int N = int.Parse(textBox2.Text.Trim());
string str = comboBox1.Text;
switch (str)
{
case "加": textBox3.Text = at.addition(M, N).ToString(); break;
case "减": textBox3.Text = at.subtraction(M, N).ToString(); break;
case "乘": textBox3.Text = at.multiplication(M, N).ToString(); break;
case "除": textBox3.Text = at.division(M, N).ToString(); break;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}