I need to extract only the last part of a string after a /
character.
I have tried with LastIndexOf
, but it fails.
Any solution?
var strDiv2 = tbxAff.Substring(tbxAff.IndexOf(" / "), /*value is missing*/ );
dblDiv2 = Convert.ToDouble(strDiv2);`
Use the String.Split()
function:
string[] y = tbxAff.Text.Split(new string[] { " / " }, StringSplitOptions.RemoveEmptyEntries);
Then use it like this:
string strDiv2 = y[1] // Second Part
dblDiv2 = Convert.ToDouble(strDiv2);