Dynamic formatting of strings

  • Thread starter Thread starter Michael Lofgren
  • Start date Start date
M

Michael Lofgren

Hi,

Can anyone tell me how to code such that the width field is dynamic? That is
for example, so that the -53 below could be passed in as an integer or
something? I am pretty sure I could do this using one Format call to create
a format string and a second Format call that uses it, but is there a more
elegant solution?
eventstr.AppendFormat(null, "{0}{1,-11} {2,-53}\r\n", eventtime, eventtype,
classmethod);


Michael
 
Michael said:
Can anyone tell me how to code such that the width field is dynamic? That is
for example, so that the -53 below could be passed in as an integer or
something? I am pretty sure I could do this using one Format call to create
a format string and a second Format call that uses it, but is there a more
elegant solution?
eventstr.AppendFormat(null, "{0}{1,-11} {2,-53}\r\n", eventtime, eventtype,
classmethod);

So far as I know, two Format calls is the way to go.
 
Back
Top