CS0250 – Do not directly call your base class Finalize method. It is called automatically from your destructor

C# Compiler Error

CS0250 – Do not directly call your base class Finalize method. It is called automatically from your destructor

Reason for the Error

You’ll receive this error in your C# program when you attempt to call the Finalize method of the base class.

For example, lets try to compile the below code snippet.

namespace DeveloperPubNamespace
{
    public class BaseEmployee
    {

    }
    public class Employee : BaseEmployee
    {
        ~Employee()
        {
            // This will result with error code CS0250
            base.Finalize();
        }
    }
    class Program
    {
        public static void Main()
        {

        }
    }
}

You will receive the error code CS0250 in your C# program because we are explicitly calling the Finalize method of the base class from the destructor of the Employee class.

Error CS0250 Do not directly call your base type Finalize method. It is called automatically from your destructor. DeveloperPublish C:\Users\SenthilBalu\source\repos\ConsoleApp3\ConsoleApp3\Program.cs 12 Active

CS0250 – Do not directly call your base class Finalize method. It is called automatically from your destructor

Solution

C# Compiler doesnot allow you to force cleanup of the base class resources.

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...