Naval Navc Naval Navc - 1 year ago 97
C# Question

Get Substring from Url

I have some Urls string, such as:

How to get the number ("4". "11", "819") in the end of Url?

Answer Source

The other answers using string methods would be correct if this was a simple string, but since this is a URL, you should use the proper class to handle URIs:

var url = new Uri("");
var lastSegment = url.Segments.Last();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download