Why doesn't C# switch statement allow using typeof/GetType()?

后端 未结 10 2052
被撕碎了的回忆
被撕碎了的回忆 2020-12-15 08:56

As in this example:

switch ( myObj.GetType ( ) )
{
    case typeof(MyObject):
        Console.WriteLine ( \"MyObject is here\" );
        break;
}

10条回答
提交回复
热议问题