Check if types are castable / subclasses

后端 未结 6 2246
执笔经年
执笔经年 2020-12-07 00:32

I have they type of two members as strings - and not as a Type instance. How can I check if the two types are castable? Let\'s say string one is \"System.Windows.Forms.Label

6条回答
  •  我在风中等你
    2020-12-07 01:25

    Simplest way is value.GetType().IsSubclassOf(typeof(Control)) Basically, Type.IsSubclassOf method do what you need

提交回复
热议问题