110,534
社区成员
发帖
与我相关
我的任务
分享
public delegate void MyDel();
public class myDel
{
public static event MyDel catshout;
public static void ratrun()
{
Console.WriteLine("run");
}
public static void test()
{
catshout += delegate {
Console.WriteLine(1);
};
}
}
//调用该方法 没有输出"run"
myDel.test();
public static void test()
{
catshout += delegate {
Console.WriteLine(1);
};
catshout();
}
public delegate void MyDel();
public class myDel
{
public static event MyDel catshout;
public static void ratrun()
{
Console.WriteLine("run");
}
public static void test()
{
catshout += new MyDel(ratrun);
}
}
源码应该是这样的。。。。