>I need to get the first 10 characters from a string. If the string is less than 10, I want to pad it to the right with spaces. If the string is over 10, I want to chop off everything pass position 10.
>
>How can I do this?
>
>
>Example:
>"Joe.Smith" // I need 1 space added to the end. 'Joe.Smith '
>"Steve.Smith" // I need 'Steve.Smit'
>
>
Try something like this:
string name = "Joe.Smith";
name = name.PadRight(10, ' ').Substring(0, 10);