C# Error CS0535 – ‘class’ does not implement interface member ‘member’

C# Compiler Error

CS0535 – ‘class’ does not implement interface member ‘member’

Reason for the Error

You’ll get this error in your C# code when the class that is derived from the interface does not implement one or more of the interface members.

For example, let’s try to compile the below C# code snippet.

using System;

namespace DeveloperPublishConsoleCore
{
    public interface IEmployee
    {
        void GetDetails();
    }

    public class Employee : IEmployee
    { 

    }  
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("DeveloperPublish Hello World!");
        }
    }
}

In the above example, the Employee class derives from the interface IEmployee but doesnot implement the method GetDetails(). This results in the C# error code CS0535.

Error CS0535 ‘Employee’ does not implement interface member ‘IEmployee.GetDetails()’ DeveloperPublishConsoleCore C:\Users\senth\source\repos\DeveloperPublishConsoleCore\DeveloperPublishConsoleCore\Program.cs 10 Active

C# Error CS0535 – 'class' does not implement interface member 'member'

Solution

In C#, it is mandatory for the class to implement all the members of the interface from which it derives. You can fix the above code by implementing the method GetDetails() in the Employee class.

using System;

namespace DeveloperPublishConsoleCore
{
    public interface IEmployee
    {
        void GetDetails();
    }

    public class Employee : IEmployee
    {
        public void GetDetails()
        {
            // Write your Logic here
        }
    }
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("DeveloperPublish Hello World!");
        }
    }
}

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