Naval Navc Naval Navc - 2 months ago 6x
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?


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();