📜  如何在控制台应用程序中居中文本 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:13.529000             🧑  作者: Mango

代码示例1
//copy this into your IDE
    //write your own text instead of "Custom Text" and run
    string textToEnter = "Custom Text";
    Console.WriteLine(String.Format("{0," + ((Console.WindowWidth / 2) + (textToEnter.Length / 2)) + "}", textToEnter));
    Console.Read();