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

首頁 > 編程 > .NET > 正文

.NET 擴展實現代碼

2024-07-10 13:21:59
字體:
來源:轉載
供稿:網友
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");
}
}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 西林县| 凯里市| 乐亭县| 屏东县| 醴陵市| 黔西| 平顶山市| 博爱县| 休宁县| 汨罗市| 万年县| 夏津县| 韶山市| 东城区| 油尖旺区| 麦盖提县| 湛江市| 霍邱县| 桂平市| 芦溪县| 宁波市| 内乡县| 潞城市| 罗甸县| 井冈山市| 镇巴县| 雷波县| 双鸭山市| 塔河县| 神池县| 即墨市| 永新县| 盐边县| 晋江市| 乌拉特中旗| 泽库县| 汾西县| 同心县| 汤原县| 汤阴县| 三门峡市|