我有一个类可以创建一个边框上具有不同颜色的 Box。我的代码出现错误,提示“方法'SetCursorPosition'没有重载需要3个参数。这是我的代码:
class TitledBox : ColoredBox
{
private string title;
private ConsoleColor titleColor;
public TitledBox(Point p, int width, int height, ConsoleColor backColor, string title, ConsoleColor titleColor)
: base(p, width, height, backColor)
{
if (title.Length > width)
this.title = title.Substring(0, width);
else
this.title = title;
this.titleColor = titleColor;
}
public override void Draw()
{
for (int j = 0; j < height; j++)
{
Console.SetCursorPosition(p.X, p.Y, + j);
Console.BackgroundColor = backColor;
if ( j == 0)
{
Console.ForegroundColor = titleColor;
Console.Write(title);
for (int i = 0; i < width - title.Length; i++)
{
Console.Write(' ');
}
}
else
{
for (int i = 0; i < width; i++)
Console.Write(' ');
}
}
}
}
关于我做错了什么的任何想法?