C# String builder, displaying data nicely spaced out.
- by Sef
Hello,
I am wondering how exactly can i order my date nicely in a stringbuilder?
Meaning something equal to ("{0,2}", ....) to space the data nicely out.
I do not want to use consolewrites of any kind, so the class can be re-used in a form, console code etc...
Currently i am using " " for the spacing, but in overall it does not give a proper display.
(it messed up when i have numbers with more then 1 digit)
public override string ToString()
{
StringBuilder builder = new StringBuilder();
foreach (int value in tabel)
{
builder.Append(value); // should have something similiar to ("{0,2}", ....)
builder.Append(" "); // should have something similiar to ("{0,2}", ....)
}
builder.Append("(top:");
builder.Append(top);
builder.Append(")");
return builder.ToString();
}/*ToString*/
Regards.