I've recently made a switch from Java to C# and I'm wondering why I'm unable to set the property of a derived class as shown in the example below:
public abstract class Vehicle
{
private string name;
public void setName(string name)
{
this.name = name;
}
}
public class Car : Vehicle
{
setName("Car")
}
Your method can't be called directly in the class body, it has to be called from another method (the constructor for instance).
Try this: