Can StringBuilder have columns?

danyeungw

Well-known member
Joined
Aug 30, 2005
Messages
73
Programming Experience
10+
Can StringBuilder have columns? For example, the first column is comapny name and the second column is address.

Instead of
ABC Company 1234 Main Street
XYZ Corp 789 San Diego Ave.

Thanks.
DanYeung
 
Yes, stringbuilder.AppendFormat (or String.Format) can do column alignment, this is called composite formatting.
 
The formatted string is just a simple string, if you want some thing from a string you have to parse it. With fixed sized column you at least can grab a fixed substring, but this all sounds backwards to me, there are probably better ways of managing data.
 
StringBuilder doesn't have rows, it only contains a single string. So you have to keep count yourself while adding lines.
 
Back
Top