Re: How do I make a string longer??
Tech-Archive recommends: Fix windows errors by optimizing your registry
- From: "Ignacio Machin \( .NET/ C# MVP \)" <machin TA laceupsolutions.com>
- Date: Thu, 25 Jan 2007 14:05:05 -0500
Hi,
"roger_27" <roger27@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A5C1D5F9-3BD4-4461-9253-239CE2FF0693@xxxxxxxxxxxxxxxx
| hey, I have a bunch of strings that are 20 characters long. The user
inputs
| data 10 characters long and I am inserting data at character spot number
11.
|
| well what if the user inputs data that is 5 characters long? how do I
insert
| spaces untill it is 10 characters long, so I can still use the
string.insert
| at space number 11?
Remember that String is an inmutable class, this means that if you try to
modify it in any way you are creating a new instance.
With that remark in place you can use Pad or simply adding a new string like
corrected = user_input + new String( ' ', 10 - user_input);
Take also a look at StringBuilder class
--
Ignacio Machin
machin AT laceupsolutions com
.
Relevant Pages
- Re: How to convert Infix notation to postfix notation
... If this is for an error message, why isn't it using stderr for its output? ... array of 15 characters, and you call this function with the limit 15 on ... Making sure that the only string I allocate and append to, ... because mulFactor in all versions must needs incorporate the functions ... (comp.lang.c) - Re: Prothon should not borrow Python strings!
... """It does not make sense to have a string without knowing what encoding ... same cul de sac as Python. ... Prothon_String_As_ASCII // raises error if there are high characters ... Python's split between byte strings and Unicode strings is ... (comp.lang.python) - Re: Letter to US Sen. Byron Dorgan re unpaid overtime
... put them in stupid places. ... Programming is difficult (as you must surely appreciate, ... > strings will be in the range 1...1000 characters. ... impose an artificially small limit on string length." ... (comp.programming) - Re: Byte Array to String
... retrieved text will mismatch the original characters. ... encoding the characters. ... Dim strFileData as String ... (microsoft.public.dotnet.framework.aspnet) - Re: A note on personal corruption as a result of using C
... impossible to write effective string validation routines by definition ... (Note that a string literal may contain embedded null characters; ... without resorting to abusive language. ... In practice, programmers typically use "struct" ... (comp.programming) |
|