Inheritance and Destructors in C#

后端 未结 7 975
灰色年华
灰色年华 2021-02-13 19:30

According to this, it states that Destructors cannot be inherited or overloaded. In my case, for all subclasses, the destructors will be identical. Is this pretty m

7条回答
  •  情书的邮戳
    2021-02-13 19:51

    It's not a destructor in C#. It's known as a Finializer; and when it is called is non-deterministic. You actually can't count on it to be called at all.

    Finalizers are used as a last resort to clean up unmanaged resources. You should look into the Dispose pattern.

提交回复
热议问题