Quantcast
Viewing all articles
Browse latest Browse all 8156

Variable padding for String.Format()

Hi,

the question have been asked before but none of my tests works and I don't know why.

string name1 = "TEST";
string name2 = "Description";
maxLength = 10;
string format = "{0:" + maxLength + "} = {1}";
buffer = string.Format(format, name1, name2);

The debugger show me :

format = "{0:10} = {1}"
buffer = "TEST = Description"

Why no space is inserted for 'TEST' string ?

Thanks,

Vincent


Viewing all articles
Browse latest Browse all 8156

Trending Articles