SUN SUN - 3 months ago 25
ASP.NET (C#) Question

extract numerical values from string after dash (-)

I have string value like this Rs.100 - Rs.250 Now I want only 250 from this string.

I tried this but it's not getting output

var result = str.Substring(str.LastIndexOf('-') + 1);


UPDATE

string result = price.Text;
string[] final_result = result.Split('.');
dynamic get_result = final_result(1).ToString();
price.Text = final_result.ToString;

Answer

Do it like this:

    string str = "Rs.100-Rs.250";
        var result = str.Substring(str.LastIndexOf('-') + 1);


        String[] final_result = result.Split('.');
        var get_result = final_result[1].ToString();

this will get 250 as you wanted.