手机
当前位置:查字典教程网 >编程开发 >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实现md5加密

ASP.NET 页面刷新的实现方法

ASP.NET常用代码

ASP.NET 动态写入服务器端控件第1/2页

Asp.Net URL重写的具体实现

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

在ASP.Net中实现flv视频转换的代码

.Net 文本框实现内容提示的实例代码

ASP.NET 高性能分页代码

asp.net 操作excel的实现代码

精品推荐
分类导航