using System;
using System.Collections.Generic;
using System.Text;namespace ConsoleApplication14
{
class cat
{
public delegate void catjiaoEventHanler(object send, cat.catjiaoeventArgs e);
public event catjiaoEventHanler catjiaoevent;
public void Catjiao()
{
Console.WriteLine("咪咪。咪咪咪咪咪咪。咪咪咪咪");
if (catjiaoevent != null)
{ catjiaoevent(this, new catjiaoeventArgs());
}
}
class mouse
{ public static void Ting(object send, catjiaoeventArgs e)
{
Console.WriteLine("mouse跑了");
}
}
public class catjiaoeventArgs : EventArgs
{
public DateTime dt; public catjiaoeventArgs()
{
dt = DateTime.Now;
}
}
class Program
{
static void Main(string[] args)
{
cat a = new cat();
mouse mu = new mouse();
a.catjiaoevent += new catjiaoEventHanler(mouse.Ting);
a.Catjiao();
}
}
}
}
你的代码真乱,这样就不出错了但你想练习猫抓老鼠的代理可不是这样的
using System.Collections.Generic;
using System.Text;namespace ConsoleApplication14
{
class cat
{
public delegate void catjiaoEventHanler(object send, cat.catjiaoeventArgs e);
public event catjiaoEventHanler catjiaoevent;
public void Catjiao()
{
Console.WriteLine("咪咪。咪咪咪咪咪咪。咪咪咪咪");
if (catjiaoevent != null)
{ catjiaoevent(this, new catjiaoeventArgs());
}
}
class mouse
{ public static void Ting(object send, catjiaoeventArgs e)
{
Console.WriteLine("mouse跑了");
}
}
public class catjiaoeventArgs : EventArgs
{
public DateTime dt; public catjiaoeventArgs()
{
dt = DateTime.Now;
}
}
class Program
{
static void Main(string[] args)
{
cat a = new cat();
mouse mu = new mouse();
a.catjiaoevent += new catjiaoEventHanler(mouse.Ting);
a.Catjiao();
}
}
}
}
你的代码真乱,这样就不出错了但你想练习猫抓老鼠的代理可不是这样的
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货