最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

.NET 擴(kuò)展實現(xiàn)代碼

 更新時間:2008年09月14日 08:30:40   作者:  
增強(qiáng).net的功能需要用到了擴(kuò)展實現(xiàn)代碼,大家可以參考下
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");
}
}

相關(guān)文章

最新評論

乃东县| 安阳县| 文山县| 奉化市| 博爱县| 邛崃市| 墨竹工卡县| 民勤县| 阜城县| 平谷区| 固镇县| 陇川县| 玉门市| 曲麻莱县| 临安市| 嘉荫县| 湛江市| 江津市| 青海省| 阳西县| 罗山县| 普兰店市| 营口市| 时尚| 河北区| 弥渡县| 渭源县| 黄龙县| 桂东县| 睢宁县| 宁晋县| 玉屏| 新宁县| 尉氏县| 苏尼特左旗| 南安市| 明水县| 平安县| 老河口市| 莲花县| 繁峙县|