-1

我想创建一个程序,在控制台应用程序中使用任何前景色和背景色在任何给定坐标处打印出一个字符串。例如,如果字符串包含“Hello!” 我想要“你好!” 要在控制台中写出的文本,具体取决于我放置坐标的位置。这是我的代码:

class PrintString
{
    public int x, y; // Coordinates
    public string Text = "Hello!";
    ConsoleColor color;

    public PrintString(int x, int y, string Text)
    {
        Console.ForegroundColor = color;
        Console.SetCursorPostion(x, y);
        Console.Write(Text);
        Console.ResetColor();
    }

    public void Draw()
    {
        // Here I have no idea on how I should write the code for drawing the string?
    }
}

当我运行此代码时,我得到:错误 4System.Console不包含SetCursorPostion

我的问题是,我错过了什么才能如我所愿?

4

1 回答 1

0

正如编译器所说:

没有办法SetCursorPostion

这是一个错字:

利用Console.SetCursorPosition(top,left);

于 2013-02-09T16:39:27.307 回答