接口错误,是什么原因?

yfpfly 2011-08-17 08:39:41
internal interface IFormView
{
abstract event UpdateCommandEventHandler UpdateCommand;

ViewController Controller { get; }

System.Windows.Forms.Form Form { get; }

IFormPanel TaskPanel { get; }



public delegate void UpdateCommandEventHandler(object sender, EventArgsViewCommand e);

}

错误:
UpdateCommandEventHandler 接口不能声明类型,应怎么改?
...全文
681 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
guoyanhong1111 2011-08-17
  • 打赏
  • 举报
回复
你们是不是VS的版本不同呢!
liusahara 2011-08-17
  • 打赏
  • 举报
回复
学习!
threenewbee 2011-08-17
  • 打赏
  • 举报
回复
事件可以在接口定义,而且你的代码在我这里都编译通过的。你看看别的地方是否有问题。
threenewbee 2011-08-17
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 yfpfly 的回复:]
caozhy 大侠

派生类有用UpdateCommandEventHandler 这个功能,移出来也不行
[/Quote]
派生类只要 using 包含 UpdateCommandEventHandler 定义的命名空间就可以用。
bios8086 2011-08-17
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 yfpfly 的回复:]

caozhy 大侠

派生类有用UpdateCommandEventHandler 这个功能,移出来也不行
[/Quote]
事件好像不能在接口里定义的
yfpfly 2011-08-17
  • 打赏
  • 举报
回复
caozhy 大侠

派生类有用UpdateCommandEventHandler 这个功能,移出来也不行
yfpfly 2011-08-17
  • 打赏
  • 举报
回复
从接口派生的类引用了 UpdateCommandEventHandler
threenewbee 2011-08-17
  • 打赏
  • 举报
回复
我这里编译正常啊
yfpfly 2011-08-17
  • 打赏
  • 举报
回复
求高人指点,
在线等
yfpfly 2011-08-17
  • 打赏
  • 举报
回复
internal interface IFormView
{
//abstract event UpdateCommandEventHandler UpdateCommand;
event UpdateCommandEventHandler UpdateCommand;

ViewController Controller { get; }

System.Windows.Forms.Form Form { get; }

IFormPanel TaskPanel { get; }



//public delegate void UpdateCommandEventHandler(object sender, EventArgsViewCommand e);

}
public delegate void UpdateCommandEventHandler(object sender, EventArgsViewCommand e);

改成这样,报错
yfpfly 2011-08-17
  • 打赏
  • 举报
回复
移出来会有更多错误,
错误 CS0426: 类型“Lighthouse.LmsExpress.AppView.IFormView”中不存在类型名称“UpdateCommandEventHandler”
threenewbee 2011-08-17
  • 打赏
  • 举报
回复
abstract event UpdateCommandEventHandler UpdateCommand;

=>

event UpdateCommandEventHandler UpdateCommand;
threenewbee 2011-08-17
  • 打赏
  • 举报
回复
把 public delegate void UpdateCommandEventHandler(object sender, EventArgsViewCommand e);
移出来。

110,566

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧