In my C# Console program I have 4 variables. Their names and types are as follows:
int ID
bool Status
bool Available
int Count
I would like to be able to print them to the Console, nicely indented as follows:
However, when I use the tabs "\t", to format my string, it does not take into account the text width, and all the values are indented waywardly as follows:
How do I fix this? I don't want to use any third party libraries, but simply .NET functionality such as String.Format().
Try a padding
You can pad them with spaces like this:
And if you want to right-align them instead:
I set the padding to the longest possible length of an integer or boolean represented in string form. You may have to adjust it to account for your column titles.