Getting a System.Type from type's partial name

前端 未结 7 846
梦谈多话
梦谈多话 2020-11-27 07:18

I want to get a System.Type given only the type name in a string.

For instance, if I have an object:

MyClass abc = new MyCl         


        
7条回答
  •  再見小時候
    2020-11-27 07:36

    Type type = Type.GetType("MyClass");
    

    Make sure to include the namespace. There are overloads of the method that control case-sensitivity and whether an exception is thrown if the type name isn't found.

提交回复
热议问题