hi....
how to use the substring function.I have a string like (sr1234pr).ineed to get 1234 from this.'sr' and 'pr' is assigned in a variable.reply me plz...
Substring in c#
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Hirendra SisodiyaRank #258 · 9.8K reputationPosted Mar 11, 2010, 12:08 AM EST
string str = "sr1234pr";
string tempstr = str.Substring(2, str.Length - 4);
or you need to find substring from another format let me know
thanks
Amit ChoudharyRank #145 · 15.8K reputationPosted Mar 11, 2010, 12:23 AM EST
Hirendra's code is right.. but if you want to utilize "sr" and "pr" string values in differet variables then
string str = "sr1234pr";
string tempstr = str.Substring(2, str.Length - 4);
string [] SplittedStrings=new SplittedStrings[10];
SplittedStrings=s.Split(new string[] { tempstr }, StringSplitOptions.RemoveEmptyEntries);
now you have the values splitted from str="sr1234pr" in an array. you can access them using an indexes.
Please mark as answer if it helps.