C# Compiler Error
CS0574 – Name of destructor must match name of class
Reason for the Error
You will get this error in your C# code when the name of the destructor or finalizer is different from the class name followed by the tilde symbol.
For example, let’s compile the below C# program
using System;
namespace DeveloperPublishConsoleCore
{
public class Employee
{
~ Employee1()
{
}
}
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("DeveloperPublish Hello World!");
}
}
}You will receive the error code CS0574 because you have a destructor with the name Employee1 which is different from the class name “Employee”.
Error CS0574 Name of destructor must match name of type DeveloperPublishConsoleCore C:\Users\senth\source\repos\DeveloperPublishConsoleCore\DeveloperPublishConsoleCore\Program.cs 7 Active

Solution
You can fix this error in your C# program by ensuring that the name of the destructor matches with the name of the class.