I know that this can be done:
How can I add spacing here so that the string has spacing?
What I need to do is something like this:
Can you elaborate? You question is very unclear.
edited the question
If you have a general idea of how long your values will be you can right-align them with {0,5}
or left-align with {0,-5}
This is the right solution. Using tabs is a horrible way to go about it.
This is the correct answer.
None of the answers so far have linked to the documentation and I find that the docs almost always answer every question a beginner might have.
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated
Here’s a simple nonsensical example to illustrate.
I didn’t bother space padding the rightmost column, but you can if you like.
You should look up string.PadRight. it’s an easy way to create character aligned columns.
If you mean leading or trailing spaces, look up the padding functions.
The “quick and dirty” method to achieve that is to use tab control characters in your string:
var header = “AtBtC”;
var row1 = “1234tabcdtzaq1”;
the “t” combination will be interpreted as a tab control character and thus will align your data into columns.
Until you have a string that is longer than the others and causes the tabs to be misaligned.
string. Format(“{0}tt{1}tt{2}”, var1, var2, var3) ;
t is a tab character.
Is there a way to pad the strings?
C# devs
null reference exceptions