PadRight

  • Thread starter Thread starter john sutor
  • Start date Start date
J

john sutor

Is there something wrogn with this syntax? It does not put in the padded
characters.

string hk="Assembly";

hk.PadRight(35,'-');

this.textBox1.Text=hk + "Test";

The output is AssemblyTest
 
John,
You never do anything with the result of PadRight, remember that PadRight is
a function that returns a new string. Remember that strings are immutable,
any String method that "modifies" a string returns a new instance of the
modified string, they do not change the specified instance of the string.

Try:
string hk="Assembly";

hk = hk.PadRight(35,'-');

this.textBox1.Text=hk + "Test";

Hope this helps
Jay
 
Back
Top