Increment value of an string [Resolved]

Posted by Sudhakar_A under Windows Forms on 9/5/2013 | Points: 10 | Views : 939 | Status : [Member] | Replies : 2
string sequenceno="0003";

I wan to increment value of the string by 1 wen a for loop run i.e string sequenceno should be "0004"- in 1st loop & "0005" in 2nd loop and soon.

Please help me sort out.
Thnk's in advance




Responses

Posted by: Allemahesh on: 9/5/2013 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
You can use the below method.

Here you need to set the i max value.
In my below example, I have set 50.

string sequenceno="0003";
for(int i=0; i<50; i++)
{
sequenceno = convert.ToString(Convert.toInt32(sequenceno) + 1);
}

Happy coding.

Sudhakar_A, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Allemahesh on: 9/5/2013 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
You can use the below code as well.

int a = 50;
string sequenceno="0003";
for(int i=0; i<a; i++)
{
sequenceno = convert.ToString(Convert.toInt32(sequenceno) + 1);
//Do you process.
}

Happy coding.

Sudhakar_A, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response