帮忙看看这段代码中用到的C#语法或特性

josxhn 2011-09-07 03:20:43


interface IClientGateWay
{
bool isTcpConnected();
Passport Passport { get; }
void Send<T,R>(T sendCommand, Action<R> commitCallback, Action timeoutCallback, Action<Exception> errorCallback);
R Send<T,R>(T sendCommand);
void UdpSend<T>(T sendCommand);
event Action<object> Notify;
}



主要是
void Send<T,R>(T sendCommand, Action<R> commitCallback, Action timeoutCallback, Action<Exception> errorCallback);
R Send<T,R>(T sendCommand);
以及其中参数列表里的 Action<R> commitCallback 和 Action<Exception> errorCallback
用到了什么特性。

另外在接口中定义事件如何实现?
event Action<object> Notify;



...全文
71 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
康少_小贱 2011-10-11
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 magic_stru 的回复:]

void Send<T,R>(T sendCommand, Action<R> commitCallback, Action timeoutCallback, Action<Exception> errorCallback),这个是泛型方法,Action<T>泛型委托,需要在继承接口的类中实现事件逻辑,在需要触发事件的时候调用event Action<object> Notify:if(Noti……
[/Quote]

泛型
magic_stru 2011-10-11
  • 打赏
  • 举报
回复
void Send<T,R>(T sendCommand, Action<R> commitCallback, Action timeoutCallback, Action<Exception> errorCallback),这个是泛型方法,Action<T>泛型委托,需要在继承接口的类中实现事件逻辑,在需要触发事件的时候调用event Action<object> Notify:if(Notify!=null){Notify(event)}
ddt7580 2011-10-11
  • 打赏
  • 举报
回复
我也记不清了 好像是type类型之类的 传递不能用T就写成object了 不知道楼主代码是不是遇到同样的问题 你试试改成<T>看看能编译不 能就不是这意思
蝜蝂 2011-10-11
  • 打赏
  • 举报
回复
Mark 一下
josxhn 2011-10-11
  • 打赏
  • 举报
回复
up两下
josxhn 2011-09-19
  • 打赏
  • 举报
回复
up一下
josxhn 2011-09-07
  • 打赏
  • 举报
回复
谢谢zw_l_1989,这些我知道的
zw_l_1989 2011-09-07
  • 打赏
  • 举报
回复
Passport Passport { get; } .net 3.5 新特性 简化属性
zw_l_1989 2011-09-07
  • 打赏
  • 举报
回复
<T,R> 泛型, 好像叫模板
Action 无返回值委托

110,536

社区成员

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

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

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