简单的delegate事件

来源:百度知道 编辑:UC知道 时间:2024/05/31 21:06:35
创建一个代理事件 要求点击10次button 弹出MessageBox提示
不能用button点击事件写
谢谢大虾。。。。

弹出的我不用按钮的点击事件,但是你点击10次这个还是要用到button的点击事件的
感谢下面的朋友和发问题的朋友(我们私聊过了)对我的肯定

http://msdn.microsoft.com/en-ca/library/system.eventargs(zh-cn).aspx
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace Win_temp
{
public partial class Form1 : Form
{
private static int num = 0;
delegate void number();
number del = new number(Temp);

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
num++;
del();
}

private static void Temp()
{
if(num==10)
MessageBox.Show("&quo