First get the center of your console by dividing the Console.WindowWidth
property by 2. Then you can take it a step further to be more precise; get the length of your string and divide that by 2. Add both of these numbers together and it will center perfect.
string textToEnter = "44444444444444444444444444444444444444444444";
Console.WriteLine(String.Format("{0," + ((Console.WindowWidth / 2) + (textToEnter.Length / 2)) + "}", textToEnter));
Console.Read();
If your not too familiar with the use of String.Format()
, take a look at this:
http://www.dotnetperls.com/string-format