how to split string in asp.net?
for example
i got value like MFA999 i want to seprate it like "MFA" and "999"
i want to increment it
MFA999
MFA1000
in asp.net
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Aug 29, 2013, 6:57 AM
Iftikar HussainPosted Aug 29, 2013, 6:55 AM
string data="MFA999";
string tempdata=data.Replace("MFA","");
int val=Convert.ToInt32(tempdata)+1;
string result="MFA"+val.ToString();
Regards,
Iftikar
Hardik PatelPosted Aug 29, 2013, 6:48 AM
as per your code i will get MFA9991000
MaheshPosted Aug 29, 2013, 6:31 AM
If your first 3 letters in a string are fixed then u can try the following
substring(3,length-1)
which will give u the number, assign it to a variable and then u can increment the number
Iftikar HussainPosted Aug 29, 2013, 6:23 AM
If your MFA word is fixed then try like this
string data="MFA999";
string tempdata=data.Replace("MFA","");
int val=Convert.ToInt32(tempdata)+1;
string result=data+val.ToString();
Regards,
Iftikar