How to use class name as parameter in C#

前端 未结 4 720
北荒
北荒 2020-11-28 11:29

what i want to do is to automatically create some object.

In Java, class can be pass as parameter, for example

Class A{

}


Object createObjectBy(         


        
4条回答
  •  温柔的废话
    2020-11-28 12:12

    Use the class Type. You can return an instance of it by call

    obj.GetType();
    

    or without an object instance

    typeof(className);
    

    I hope it helps.

提交回复
热议问题