static void Main(string[] args) { MulticastDelegatewithReturnTypes obj = new MulticastDelegatewithReturnTypes(); calDelegate cd = obj.add; cd += obj.mul; int result = cd(4, 6); Console.WriteLine("addition:" + result); Console.WriteLine("multiplication:" + result); Console.ReadKey(); }
private void button1_Click(object sender, EventArgs e) { if (button1.Text == "连接传感器") { button1.Text = "断开传感器"; calDelegate1 = new calDelegate(delagateFunAppendText); calThread = new Thread(scanCONTROL_Sample); calThread.Start(); Thread.Sleep(100); } else if (button1.Text == "断开传感器") { button1.Text = "连接传感器"; IsOver = true; Thread.Sleep(100); } this.groupBox1.Focus(); }