我正在创建一个边框框,它应该在边框处创建一个具有不同颜色的框。这是我的代码:
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(' ');
}
}
}
}
但是我在 [ ConsoleColor color = borderColor; ] ,它说“名称'borderColor'在当前上下文中不存在。有什么想法吗?