By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,680 Members | 2,091 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,680 IT Pros & Developers. It's quick & easy.

How to covert string to a new string

P: n/a
Dear all:
I develop a programe that need when I get a string , such as "123" or
"ABC",if I get string "123" and the system will help me to create new
string "124" , if I get string "ABC" and the system will help me to create
new string "ABD" , could somebody can help me how to programe it , thank you
very much.

I don't know to how to covert string as ASCII and add integer value and
covert the integer back to string, hope can support me the code I'll very
appricate, thanks.
Jul 12 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Calros,

If you want to add a number, then you can use the static ToInt32 method
on the Convert class to convert your string to an integer. Then, you can
just perform your arithmetic.

When you want to convert it back to a string, then you can call ToString
on the int variable.

As for incrementing a letter, you can create a character array and then
increment the character by one in the array.

However, you have to have logic for when you get to the letter Z.

Then you can convert the character array back to a string.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Calros Lo" <ca********@hotmail.comwrote in message
news:uY**************@TK2MSFTNGP05.phx.gbl...
Dear all:
I develop a programe that need when I get a string , such as "123" or
"ABC",if I get string "123" and the system will help me to create new
string "124" , if I get string "ABC" and the system will help me to create
new string "ABD" , could somebody can help me how to programe it , thank
you very much.

I don't know to how to covert string as ASCII and add integer value and
covert the integer back to string, hope can support me the code I'll very
appricate, thanks.

Jul 12 '06 #2

P: n/a

"Calros Lo" <ca********@hotmail.comwrote in message
news:uY**************@TK2MSFTNGP05.phx.gbl...
Dear all:
I develop a programe that need when I get a string , such as "123" or
"ABC",if I get string "123" and the system will help me to create new
string "124" , if I get string "ABC" and the system will help me to create
new string "ABD" , could somebody can help me how to programe it , thank
you very much.

I don't know to how to covert string as ASCII and add integer value and
covert the integer back to string, hope can support me the code I'll very
appricate, thanks.
What happens when "ABC" eventually becomes "ABZ"? Does the previous letters
get up'ed? Such as "ACA"? If so, what happens at "ZZZ"? Does it become
"AAAA" or "ZZZA"? Need more info if we are to help :)

Mythran

Jul 12 '06 #3

P: n/a
Hi~
Thank for you point my problem, I consider that If I get the string of end
letter is"Z" I'll take ignore, in other word If I get string "ABZ" than keep
the string orginal "ABZ" or not do anything.

I just want to know how If I get "123" than get "124" thanks everybody, I
will appreaciate.

"Mythran" <ki********@hotmail.comREMOVETRAILwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>
"Calros Lo" <ca********@hotmail.comwrote in message
news:uY**************@TK2MSFTNGP05.phx.gbl...
>Dear all:
I develop a programe that need when I get a string , such as "123" or
"ABC",if I get string "123" and the system will help me to create new
string "124" , if I get string "ABC" and the system will help me to
create new string "ABD" , could somebody can help me how to programe it ,
thank you very much.

I don't know to how to covert string as ASCII and add integer value and
covert the integer back to string, hope can support me the code I'll very
appricate, thanks.

What happens when "ABC" eventually becomes "ABZ"? Does the previous
letters get up'ed? Such as "ACA"? If so, what happens at "ZZZ"? Does it
become "AAAA" or "ZZZA"? Need more info if we are to help :)

Mythran

Jul 12 '06 #4

P: n/a
Calros Lo wrote:
Dear all:
I develop a programe that need when I get a string , such as "123" or
"ABC",if I get string "123" and the system will help me to create new
string "124" , if I get string "ABC" and the system will help me to create
new string "ABD" , could somebody can help me how to programe it , thank you
very much.

I don't know to how to covert string as ASCII and add integer value and
covert the integer back to string, hope can support me the code I'll very
appricate, thanks.

string s = "abc";
char subChar = s[2]; // last character
subChar++;
Console.WriteLine(s.Substring(0,2) + subChar);

HTH

JB
Jul 13 '06 #5

P: n/a
Hi Mythran
Can you point me , If I get string "ABZ" do you have any solution , if I
get it.
I think If I get string "ABZ" I want convert it as "ABZA" can you help me to
programe
how to write it, thank you very much.

"Mythran" <ki********@hotmail.comREMOVETRAILwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>
"Calros Lo" <ca********@hotmail.comwrote in message
news:uY**************@TK2MSFTNGP05.phx.gbl...
>Dear all:
I develop a programe that need when I get a string , such as "123" or
"ABC",if I get string "123" and the system will help me to create new
string "124" , if I get string "ABC" and the system will help me to
create new string "ABD" , could somebody can help me how to programe it ,
thank you very much.

I don't know to how to covert string as ASCII and add integer value and
covert the integer back to string, hope can support me the code I'll very
appricate, thanks.

What happens when "ABC" eventually becomes "ABZ"? Does the previous
letters get up'ed? Such as "ACA"? If so, what happens at "ZZZ"? Does it
become "AAAA" or "ZZZA"? Need more info if we are to help :)

Mythran

Jul 13 '06 #6

P: n/a
Hi,
"Calros_Lo" <ca********@hotmail.comwrote in message
news:OD**************@TK2MSFTNGP03.phx.gbl...
Hi Mythran
Can you point me , If I get string "ABZ" do you have any solution , if I
get it.
I think If I get string "ABZ" I want convert it as "ABZA" can you help me
to programe
Well if you do not know what to do in that case maybe you want to rethink
the entire thing over :)

Start with thinking why are you doing it and what you want from it.

Un Saludo,

--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Jul 13 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.