private void button1_Click(object sender, EventArgs e) { //动态加载程序集并创建对象 IFunction objfunction = (IFunction)Assembly.LoadFrom("Function.dll").CreateInstance("Function.Function"); int a = Convert.ToInt32(this.textBox1.Text); int b = Convert.ToInt32(this.textBox2.Text); string result = "0"; //通过接口完成计算 switch (this.comboBox1.SelectedIndex) { case 0: result = objfunction.Add(a, b).ToString(); break; case 1: result = objfunction.Sub(a, b).ToString(); break; case 2: result = objfunction.Multiply(a, b).ToString(); break; case 3: result = objfunction.Division(a, b).ToString(); break; default: break; } this.textBox3.Text = result; }