本文介绍了我在以下代码中遇到错误,我指定了错误行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
using System;
namespace wildert
{
public class Metronome
{
public event TickHandler Tick;
public EventArgs e = null;
public delegate void TickHandler(Metronome m, EventArgs e);
public void Start()
{
while (true)
{
System.Threading.Thread.Sleep(3000);
if (Tick != null)
{
Tick(this, e);
}
}
}
}
public class Listener
{
public void Subscribe(Metronome m)
{
m.Tick += new Metronome.TickHandler(HeardIt);//I am getting error here
}
private void HeardIt(Metronome m, EventArgs e)
{
System.Console.WriteLine("HEARD IT");
}
}
class Test
{
static void Main()
{
Metronome m = new Metronome();
Listener l = new Listener();
l.Subscribe(m);
m.Start();
}
}
}
错误是:错误1无法将类型"Event_Delegates.Metronome.TickHandler"隐式转换为"System.EventHandler"
谁能帮我.是的,我正在收到此错误,请在上面给出完整的代码段....
Erroe is:Error1Cannot implicitly convert type ''Event_Delegates.Metronome.TickHandler'' to ''System.EventHandler''
Can any one help me. Y i am getting this error ,i given the full code snippet please above....
推荐答案
这篇关于我在以下代码中遇到错误,我指定了错误行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!