Get error ‘ClassLibrary3.Class1.a’ is a ‘property’ but is used like a ‘type’ when i want to access the property of base class.
namespace ClassLibrary3
{
public class Class1
{
public int a { get; set; }
public int A { get; set; }
}
public class test : Class1
{
a=1; // error 'ClassLibrary3.Class1.a' is a 'property' but is used like a 'type'
public void hello()
{
a = 10;
}
}
}
Yes; that is normal. With the exception of field initializers, the code must be in a method. That isn’t a field initializer.
Either assign
a=1;in the derived constructor, or create an overloaded constructor and pass1to the base type’s constructor.So either:
Or: