Is there a one-liner way of setting a string
to a fixed length (in C#), either by truncating it or padding it with spaces (' '
).
For example:
string s1 = "abcdef";
string s2 = "abc";
after setting both to length 5
, we should have:
"abcde"
"abc "