Create object instance without invoking constructor?

后端 未结 11 1991
不知归路
不知归路 2020-11-28 05:01

In C#, is there a way to instantiate an instance of a class without invoking its constructor?

Assume the class is public and is defined in a 3rd par

11条回答
  •  悲&欢浪女
    2020-11-28 05:42

    It might be possible to access the constructor via reflection and invoke it like that (but I'm not sure that it will work since the constructor is internal - you'll have to test it). Otherwise from my knowledge you can't create an object without calling the constructor.

提交回复
热议问题