Nishanth Suraj Nishanth Suraj - 2 months ago 15
ASP.NET (C#) Question

How to find the second last indexof a value in a string?

string referrer = "?404;http://stage.hello.com:80/Applications/";

referrer = referrer.Substring(referrer.LastIndexOf("/") + 1);


By doing this I get referrer value
""
as answer.

I want my referrer value to be "Applications/"

How can I achieve this?

Any help will be greatly appreciated.

Answer
referrer = referrer.Substring(referrer.Substring(0, referrer.LastIndexOf("/")).LastIndexOf("/") + 1);
Comments