C# 关于委托
例如:
public class test:Form
{
//定义委托
public delegate void GetSql(string sql);
//定义装载委托的属性
public GetSql GetSqlMethod;
private void comfirm_Click(object sender,EventArgs e)
{
GetSqlMethod(" select sysdate from dual!");
}
}
public class user
{
public void hello()
{
test t = new test();
//给委托的属性赋值一个匿名方法
t.GetSqlMethod =new delegate(string sql)
{
MessageBox.Show(sql);
}
t.Show();
}
}