Meraj99 Meraj99 - 1 year ago 139 Question

How to center text in (Console)

I want to print text "TEST" (Console.WriteLine) in the center of my console application. How would I go about doing so?

Looking for 'beginner-friendly' answers.

Answer Source

You'll need to get the console with, get the length of the string you're about to display and, subtract the second from the first, divide this in half and pad the string with this number of spaces.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download