I am new to C# and trying to figure out how inheritance works. I'm getting the following error. Why must the parent parameters be static?
Severity Code Description Project File Line Suppression State Error CS0120 An object reference is required for the non-static field, method, or property 'Rectangle.name' PurrS PATH\Sign.cs 15 Active
Parent:
namespace PurrS.Maps
{
public class Rectangle
{
protected string name;
protected int id;
protected float a;
protected float b;
protected float c;
protected float d;
protected int posX;
protected int posY;
//A----B
//| |
//C----D
public Rectangle(string name, int id, float a, float b, float c, float d, int posX, int posY)
{
this.name = name;
this.id = id;
this.a = a;
this.b = b;
this.c = c;
this.d = d;
}
}
}
Child:
namespace PurrS.Maps
{
public class Sign : Rectangle
{
string message;
public Sign(string message)
: base(name, id, a, b, c, d, posX, posY) { //This is where it fails.
this.message = message;
}
}
}