0
我正在創建一個邊框,應該在邊框處創建一個帶有不同顏色的框。這是我的代碼:顏色在一個框中,c#控制檯應用程序
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'在當前上下文中不存在。任何想法?
我沒有看到'borderColor'任何地方定義 – 2013-02-10 19:57:50
沒有'backColor'任。 – Marlon 2013-02-10 20:00:14