In .NET can a class have virtual constructor?

前端 未结 7 1739
别跟我提以往
别跟我提以往 2020-12-15 04:35

Can a class have virtual constructor??

If yes, why it is required?

7条回答
  •  醉梦人生
    2020-12-15 05:20

    Not directly, but the classic Gang of Four pattern Factory Method achieves what would amount to a virtual constructor of sorts, by deferring instantiation to subclasses.

提交回复
热议问题