I am using string builder to format my string to append and prepend white spaces at the start and end of the string
here is what I have so far:
private void button1_Click(object sender, EventArgs e)
{
String Word = textBox1.Text;
AppendPrependText(Word);
}
private void AppendPrependText (String Word)
{
int count = Convert.ToInt32(textBox2.Text);
int WordCount = Word.Count();
int totalChar = count + WordCount;
string format = "{-"+totalChar+ "," +totalChar+ "}";
StringBuilder sb = new StringBuilder();
sb.AppendLine(string.Format(format, Word));
textBox3.Text = sb.ToString();
}
but I'm getting the error incorrect format. What am i doing wrong?
.PadLeft()and.PadRight()?