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

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...