我定义了两个类:
public class ControllerEx
{
public delegate void stopMachineDelegate();
public stopMachineDelegate stopMachin; public void Add(stopMachineDelegate stopMethod)
{
this.stopMachin += stopMethod;
} public void Remove(stopMachineDelegate stopMethod)
{
this.stopMachin -= stopMethod;
} public void ShutDown()
{
this.stopMachin();
} }------------------------------------------------------------------------
public class Folder
{
public void StopFolding()
{
Console.WriteLine("Folder Closed");
} }
------------------------------------------------------------------------
我是这样调用的:
Folder folder = new Folder();ControllerEx obj = new ControllerEx();obj.Add(folder.StopFolding);提示错误:
在不带括号的情况下引用了方法“ConsoleApplication._05.Folder.StopFolding()”
public class ControllerEx
{
public delegate void stopMachineDelegate();
public stopMachineDelegate stopMachin; public void Add(stopMachineDelegate stopMethod)
{
this.stopMachin += stopMethod;
} public void Remove(stopMachineDelegate stopMethod)
{
this.stopMachin -= stopMethod;
} public void ShutDown()
{
this.stopMachin();
} }------------------------------------------------------------------------
public class Folder
{
public void StopFolding()
{
Console.WriteLine("Folder Closed");
} }
------------------------------------------------------------------------
我是这样调用的:
Folder folder = new Folder();ControllerEx obj = new ControllerEx();obj.Add(folder.StopFolding);提示错误:
在不带括号的情况下引用了方法“ConsoleApplication._05.Folder.StopFolding()”
解决方案 »
- 如果解析形如"a.b.c.d"的字段,譬如后台是如何解析XPATH的?
- 一个奇怪的问题,表面上是执行了一个 condition=false的if块,实际上可能是 Assembly的问题
- 麻烦帮我下载个东西
- winCE上的dataGrid如何加入checkbox
- 请问一下,有没有像C++运行库里一样memcmp的内存比较函数啊?谢谢了
- 在windows control中添加了panel控件,然后在其中显示图片,设定其AutoScroll = true;有两个问题!
- 请问VC.NET(C#)中点菜单就弹出一个窗口的代码如何写?
- 请问C#的高手们!VS2005编译完成之后的那个.exe文件为什么不能在别的电脑上运行?怎样解决??谢谢!
- <C# primer>的这句话怎样理解??
- 求教正则表达式
- 求一个正则表达式 匹配形如{myjs_aaaa}
- 能否在自己的Web应用程序中嵌入.net的网页设计器或其他网页设计器,怎么实现?
在以前版本可能需要这样写:
obj.Add(new ControllerEx.stopMachineDelegate(folder.StopFolding));