Compiler Warning (level 1) CS0465
Introducing a 'Finalize' method can interfere with destructor invocation. Did you intend to declare a destructor?
This warning occurs when you create a class with a method whose signature is public virtual void Finalize
.
If such a class is used as a base class and if the deriving class defines a finalizer, the finalizer will override the base class Finalize
method, not Finalize.
Example
The following sample generates CS0465.
// CS0465.cs
// compile with: /target:library
class A
{
public virtual void Finalize() {} // CS0465
}
// OK
class B
{
~B() {}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for