用户名:
密 码: 记住
您当前的位置:首页 > 网络编程 > Net教程

.NET 扩展实现代码

时间:2015-01-29  来源:互联网  作者:佚名
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");
}
}
来顶一下
返回首页
返回首页
推荐资讯
Ajax.net Sys未定义错误解决办法 Ajax.net Sys未定义错误解决办法查了很多处理日志,说的都是在Web.Config里面加什么语句,就是
.dll 文件反编译的工具软件集合 .dll 文件反编译的工具软件集合.dll 文件反编译的工具软件:Reflector for .NET Remotesoft
相关文章
栏目更新
栏目热门