相关疑难解决方法(0)

为什么C#switch语句不允许使用typeof/GetType()?

如下例所示:

switch ( myObj.GetType ( ) )
{
    case typeof(MyObject):
        Console.WriteLine ( "MyObject is here" );
        break;
}
Run Code Online (Sandbox Code Playgroud)

.net c# reflection switch-statement

13
推荐指数
5
解决办法
2万
查看次数

标签 统计

.net ×1

c# ×1

reflection ×1

switch-statement ×1