Home

Published

- 1 min read

How to center text in console application

img of How to center text in console application

The solution for this is noted below

How to center text in console application

Solution

   //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();

Try other methods by searching on the site. That is if this doesn’t work