bob*_*bby 1 c# console center readline console-application
我即将开始一个项目,这是我目前在欢迎屏幕上的内容.
string[] welcome = new string[4]
{
"Welcome",
"Choose A Option Bellow By Inputing The Number And Clicking Enter.",
"1. View C:\\Windows\\ File directory",
"2. View Your Own Custom Directory"
};
string userChoice;
for (int x = 0; x < 4; x++)
{
Console.WriteLine(
"{0," + ((Console.WindowWidth / 2) + welcome[x].Length / 2) + "}", welcome[x]);
}
Run Code Online (Sandbox Code Playgroud)
我如何集中我的读取线?那么当用户选择他们的选择时也会居中?
您可以使用CursorLeft和CursorTop属性移动光标.
所以,在你的情况下,你会做这样的事情:
Console.CursorLeft = Console.WindowWidth / 2;
// maybe -1 to center the typed number correctly
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
235 次 |
| 最近记录: |