How to covert string to a new string

  • Thread starter Nicholas Paldino [.NET/C# MVP]
  • Start date
N

Nicholas Paldino [.NET/C# MVP]

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.
 
M

Mythran

Calros Lo said:
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
 
J

John B

Calros said:
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
 
C

Calros Lo

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.
 
C

Calros_Lo

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.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


Calros_Lo said:
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,
 
C

Calros Lo

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top