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.

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