Reputation: 295
I am creating a Bordered Box that should create a box with different colors at the border. this is my code:
class BorderedBox : ColoredBox
{
public int heigth;
public int width;
ConsoleColor color = borderColor;
public BorderedBox (Point p, int width, int height, ConsoleColor backColor, ConsoleColor borderColor)
: base (p, width, height, backColor)
{
this.borderColor = borderColor;
}
public override void Draw()
{
for (int j = 0; j < height; j++)
{
Console.SetCursorPosition(p.X, p.Y + j);
for (int i = 0; i < width; i++)
{
if (i == 0 || i == width - 1 || j == 0 || j == height - 1)
Console.BackgroundColor = borderColor;
else
Console.BackgroundColor = backColor;
Console.Write(' ');
}
}
}
}
However im geting errors at the [ ConsoleColor color = borderColor; ] , it says that "the name ' borderColor ' does not exist in the current context. Any ideas?
Upvotes: 0
Views: 703
Reputation: 7747
At the point you try to assign ConsoleColor color = borderColor
, borderColor
has not been defined. I suspect you have just messed up your variable declaration and really meant:
ConsoleColor borderColor;
Instead of:
ConsoleColor color = borderColor;
Upvotes: 5