C# 如何划定边界线

C# 如何划定边界线,c#,border,C#,Border,所以我在做一个游戏,我试着在我的游戏机左侧做一条从游戏机顶部到底部的边界线。这是我的代码,用于尝试排队 Console.SetCursorPosition(0, Console.WindowWidth + 20); Console.Write(new string( '|', Console.WindowHeight)); 我这个控制台的尺寸是 Console.SetWindowSize(120, 30); Console.SetBufferSize(120, 30); 我只是一个初学者,所

所以我在做一个游戏,我试着在我的游戏机左侧做一条从游戏机顶部到底部的边界线。这是我的代码,用于尝试排队

Console.SetCursorPosition(0, Console.WindowWidth + 20);
Console.Write(new string( '|', Console.WindowHeight));
我这个控制台的尺寸是

Console.SetWindowSize(120, 30);
Console.SetBufferSize(120, 30);

我只是一个初学者,所以如果有一个简单的方法可以做到这一点,请有人帮助我。

看看我的代码,我已经找到了大部分代码,并根据您的需要进行了修改

protected static int origRow;
protected static int origCol;

static void Main(string[] args)
{
    Console.SetWindowSize(120, 30);

    // Clear the screen, then save the top and left coordinates.
    Console.Clear();
    origRow = Console.CursorTop;
    origCol = Console.CursorLeft;

    int height = Console.WindowHeight;

    for (int i = 0; i < height; i++)
        WriteAt("|", 0, i);

    // this is to force to keep the application running. Now visual studio
    // will not put some extra text at the end of the screen
    Console.ReadLine();
}

// write a string as location x,y
public static void WriteAt(string s, int x, int y)
{
    try
    {
        Console.SetCursorPosition(origCol + x, origRow + y);
        Console.Write(s);
    }
    catch (ArgumentOutOfRangeException e)
    {
        Console.Clear();
        Console.WriteLine(e.Message);
    }
}
protectedstatic int-origRow;
受保护的静态输入或输出;
静态void Main(字符串[]参数)
{
Console.SetWindowsSize(120,30);
//清除屏幕,然后保存顶部和左侧坐标。
Console.Clear();
origRow=Console.CursorTop;
origCol=Console.CursorLeft;
int height=控制台窗口高度;
对于(int i=0;i
标签只能用于有关visual studio应用程序的问题。您的代码有效吗?不知怎的,这有什么不足吗?我们需要确切地知道你目前的情况与你期望的结果有什么不同。有关更多信息,请参阅。