手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >.NET 扩展实现代码
.NET 扩展实现代码
摘要:classCommand{publicvirtualvoidExecute(){}}classInvalidOperationExcepti...

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");

}

}

【.NET 扩展实现代码】相关文章:

Asp.net 无限级分类实例代码

ASP.NET中实现模板页

ASP.net 验证码实现代码(C#)

c#将Excel数据导入到数据库的实现代码

.NET(C#)连接各类数据库代码-集锦

ASP.Net 分页控件源码

ASP.NET中的跳转 200, 301, 302转向实现代码

.NET 2.0 的压缩功能代码

asp.net高效替换大容量字符实现代码

asp.net下实现URL重写技术的代码

精品推荐
分类导航