I am trying to format a matrix in C# as shown:
1 2
10 11
I could do this in C using:
printf("%2d",number)
Is there a similar command in C#? I have tried String.Format and ToString, but I can’t figure out how to make them do what I want. I am just starting out in C#, so any suggestions would be appreciated.
This is equivalent to a
%2dfor printf, in C#:The number after the comma right aligns if positive and left aligns if negative, to the specified number of total characters (including the
numberitself).Here is a link to a helpful site with a guide on how to format integers in various ways that may help you with the rest of your problem.