C# Error CS0144 – Cannot create an instance of the abstract class or interface ‘interface’

C# Compiler Error

CS0144 – Cannot create an instance of the abstract class or interface ‘interface’

Reason for the Error

You will receive this error when you try to create an instance of the abstract class or an interface in C#.

For example, try compiling the below code snippet.

namespace DeveloperPublishNamespace
{
    interface IDeveloperPublish
    {

    }
    public class DeveloperPublish
    {
        public static void Main()
        {
            IDeveloperPublish obj = new IDeveloperPublish(); 
        }
    }

}

This will result in the C# error code CS0144 as the instance of the interface could not be created.

C# Error CS0144 – Cannot create an instance of the abstract class or interface 'interface'

Error CS0144 Cannot create an instance of the abstract type or interface ‘IDeveloperPublish’ ConsoleApp1 C:\Users\Senthil\source\repos\ConsoleApp1\ConsoleApp1\Program.cs 11 Active

Solution

Since C# doesn’t allow you to create an instance of abstract class or interface, you will need to change the logic to create an instance of an concrete class instead.

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...