-5

I want the integer to move left as you add places instead of right.

input = 1
output = "1 "

input = 10
output = "10 "


input = 100
output = "100 "

input = 1234
output = "1234 "

Not like this:

input = 1234
output = " 1234"

input = 123456
output = " 123456"
horgh
  • 17,918
  • 22
  • 68
  • 123
Mike June Bug Captain
  • 1,013
  • 1
  • 7
  • 15

2 Answers2

2

I am not exactly sure what you need but it looks like you are adding a single space at the end of the integer number in your string. You can simply do

int i = 1;
string result = i.ToString() + " ";
Habib
  • 219,104
  • 29
  • 407
  • 436
1

Use string.Format() method with format specifiers, as described here: http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/e5bc8093-5aaa-4d28-99e7-8b40bc58df3c

For example:

string.Format("{0,-4}", 123);

gives:

"123 "
Bartosz
  • 3,318
  • 21
  • 31
  • Though now when I'm looking at your formatted question, I'm not really sure if you want this, and want to append single space character instead... – Bartosz Sep 17 '12 at 04:49