手机
当前位置:查字典教程网 >编程开发 >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 扩展实现代码】相关文章:

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

ASP.NET连SQL7接口源代码

asp.net实现md5加密

ASP.Net 分页控件源码

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

ASP.net 生成缩略图的实例源代码

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

Asp.Net URL重写的具体实现

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

ASP.NET 高性能分页代码

精品推荐
分类导航