Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
PadRight
Message
 
To
05/12/2008 09:41:56
Jerry Tovar
Dana Corporation Dana It
Maumee, Ohio, United States
General information
Forum:
ASP.NET
Category:
Other
Title:
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01365649
Message ID:
01365650
Views:
9
This message has been marked as the solution to the initial question of the thread.
>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 = "Steve.Smith";
name = name.PadRight(10, ' ').Substring(0, 10);
-Paul

RCS Solutions, Inc.
Blog
Twitter
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform