国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

.NET 擴展實現代碼

2020-01-18 01:32:29
字體:
來源:轉載
供稿:網友
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");
}
}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 汪清县| 东至县| 合阳县| 怀化市| 南华县| 浮梁县| 阳朔县| 吴桥县| 临漳县| 万全县| 乐陵市| 同仁县| 女性| 梁平县| 乐亭县| 曲靖市| 视频| 黄平县| 隆林| 浑源县| 武山县| 民丰县| 融水| 承德市| 海盐县| 巧家县| 梨树县| 崇州市| 吉安县| 米泉市| 德化县| 靖州| 元谋县| 泰安市| 漳州市| 五常市| 赤壁市| 泗阳县| 天台县| 凯里市| 汕尾市|