手机
当前位置:查字典教程网 >编程开发 >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 验证码实现代码(C#)

asp.net 操作excel的实现代码

在ASP.NET 中实现单点登录

Asp.Net URL重写的具体实现

在ASP.NET中重写URL的代码

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

ASP.NET实用代码片段

ASP.NET连SQL7接口源代码

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

精品推荐
分类导航