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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 29, 2013, 2:23 AM EDT
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
Mahesh5 reputationPosted Aug 29, 2013, 2:31 AM EDT
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
Hardik PatelRank #4,439 · 343 reputationPosted Aug 29, 2013, 2:48 AM EDT
as per your code i will get MFA9991000
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 29, 2013, 2:55 AM EDT
string data="MFA999";
string tempdata=data.Replace("MFA","");
int val=Convert.ToInt32(tempdata)+1;
string result="MFA"+val.ToString();
Regards,
Iftikar
VulpesRank #55 · 29.2K reputationPosted Aug 29, 2013, 2:57 AM EDT