hi
i have to get the text entered in the textbox using substring function
Example:
the text Karthik-PVC is entered in the textbox
My code:
EmpName = txtProjEmployeeCode.Text.Substring(0, txtProjEmployeeCode.Text.LastIndexOf('-'));
output:karthik
i have to get only text after the '-'
how to write code for that using substring dynamically what ever the text i there after '-'i have to retreive
plz help me
thanks
karthik
Subtring to retreive some text from the textbox
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

VulpesRank #55 · 29.2K reputationPosted Dec 7, 2011, 12:07 AM EST
You could also replace the last line with:
EmpName = text.Split('-')[1];
Pravin MoreRank #1,419 · 1.2K reputationPosted Dec 6, 2011, 11:26 PM EST
string str1=txtProjEmployeeCode.Text;
EmpName = txtProjEmployeeCode.Text.Substring(txtProjEmployeeCode.Text.LastIndexOf('-')+1,str1.Length);
Thanks,
Pravin.