Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String.Format line break

Tags:

vb.net

i have a simple statement of code that reads:

Return String.Format("{0} {1} {2}", _var1, _var2, _var3)

i'm trying to get this formatted string to output each var on it's own line. i'm new to vb.net but i did try one thing:

"{0}\n {1}\n {2}"

that didn't work. any help?

like image 383
400_the_cat Avatar asked Jul 19 '10 04:07

400_the_cat


2 Answers

How about this:

Return String.Format( _
    "{1}{0}{2}{0}{3}{0}", _
    Environment.NewLine, _
    _var1, _
    _var2, _
    _var3 _
)

This could work too, though it's a bit "trickier":

Return New StringBuilder() _
    .AppendLine(_var1.ToString()) _
    .AppendLine(_var2.ToString()) _
    .AppendLine(_var3.ToString()) _
    .ToString()
like image 167
Dan Tao Avatar answered Nov 26 '22 05:11

Dan Tao


I'd use something like

String.Format("{1}{0},{2}{0},{3}{0}", vbcrlf, _var1, _var2, var2)
like image 40
DaveR Avatar answered Nov 26 '22 05:11

DaveR