I'm developing a simple app which counts the number of times an instance is called.In my demo class I employ a constructor to keep track of each instance. The demo class is illustrated below:
Public Class Demo
Public Sub New()
Instances += 1
End Sub
Protected Overrides Sub Finalizer()
Instances -= 1
End Sub
Public Shared Instances As Long
End Class
My question is :Why do I get the jagged lines beneath the term Finalizer? When I highlight Finalizer it states:
"Sub Finalizer cannot be declared 'Overrides' because it does not override a sub in a base class."
Yet it is my understanding that in
VB.Net I MUST use the overrides keyword since Finalizer is a method called automatically by .Net.
If I remove the 'Overrides' keyword the app appears to run as expected;however this leaves me a little confused. Can anyone explain ?