C# Error CS0117 – ‘type’ does not contain a definition for ‘identifier’

C# Compiler Error

CS0117 – ‘type’ does not contain a definition for ‘identifier’

Reason for the Error

This error can be seen when you are trying to reference an identifier that does not exist for that type. An example of this when you are trying to access a member using base. where the identifier doesnot exist in the base class.

For example, the below C# code snippet results with the CS0117 error because the the identifier Field1 is accesses using base.Field1 but it doesnot exist in the base class “Class1”.

namespace DeveloperPublishNamespace
{
    public class Class1
    {

    }
    public class Class2 : Class1
    {
        public Class2()
        {
            base.Field1 = 1;
        }
    }
    public class DeveloperPublish
    {
        public static void Main()
        {
            
        }
    }
}

Error CS0117 ‘Class1’ does not contain a definition for ‘Field1’ ConsoleApp1 C:\Users\Senthil\source\repos\ConsoleApp1\ConsoleApp1\Program.cs 11 Active

C# Error CS0117 – 'type' does not contain a definition for 'identifier'

Solution

To fix the error code CS0117, remove the references that you are trying to make which is not defined in the base class.