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

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

 更新時間:2008年09月14日 08:30:40   作者:  
增強.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)文章

最新評論

唐山市| 屯门区| 广德县| 衡水市| 沐川县| 灵丘县| 大余县| 蕉岭县| 兰州市| 会东县| 平阴县| 无锡市| 板桥市| 东光县| 藁城市| 兴业县| 温州市| 奇台县| 商洛市| 南澳县| 开鲁县| 兰州市| 清丰县| 成安县| 翁源县| 清流县| 永寿县| 浦东新区| 南宫市| 曲靖市| 隆回县| 泰和县| 巫溪县| 上饶市| 海晏县| 屯门区| 安福县| 屏东市| 安多县| 新和县| 宣武区|