当前位置: 移动技术网 > IT编程>开发语言>.net > .NET 扩展实现代码

.NET 扩展实现代码

2018年04月20日  | 移动技术网IT编程  | 我要评论

成都新南门汽车站时刻表,18av波多野结衣,搞笑故事大全

class command
{
public virtual void execute() { }
}

class invalidoperationexception<t> : invalidoperationexception
where t : command
{
public invalidoperationexception(string message) : base(message) { }
// some specific information about
// the command type t that threw this exception
}

static class commandextensions
{
public static void throwinvalidoperationexception<tcommand>(
this tcommand command, string message)
where tcommand : command
{
throw new invalidoperationexception<tcommand>(message);
}
}

class copycommand : command
{
public override void execute()
{
// after something went wrong:
this.throwinvalidoperationexception("something went wrong");
}
}

class cutcommand : command
{
public override void execute()
{
// after something went wrong:
this.throwinvalidoperationexception("something else went wrong");
}
}

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网