Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Append Whitespace to stringbuilder?

How do I append white space to a string builder? I need to insert 90 blank spaces, in VB i had this code but i was confused how to write in c# can any one help me

Dim S As New StringBuilder("HELLO")
S.Append(" "c, 90)
S.Append("WORLD")
MessageBox.Show(S.ToString) 

Thanks.

like image 851
Developer Avatar asked Sep 21 '11 04:09

Developer


People also ask

Can we append character in StringBuilder?

append(char a): This is an inbuilt method in Java which is used to append the string representation of the char argument to the given sequence. The char argument is appended to the contents of this StringBuilder sequence.

When to use string and when to use string builder?

If you are using two or three string concatenations, use a string. StringBuilder will improve performance in cases where you make repeated modifications to a string or concatenate many strings together. In short, use StringBuilder only for a large number of concatenations.

How do you create a string builder from a string?

Converting a String to StringBuilderThe append() method of the StringBuilder class accepts a String value and adds it to the current object. To convert a String value to StringBuilder object just append it using the append() method.


1 Answers

S.Append(' ', 90);

that ought to do it.

like image 90
phoog Avatar answered Nov 15 '22 13:11

phoog