Wonder if someone could point me in the right direction. What I'd like to achieve is to split a string based upon it having a '/' in it. For example if I had: www.site.com/course/123456/216 in code (c#) I'd like to be able to split the string in code so that 123456 could be assigned to variable param1 and 216 be assigned to param2 (course is the 'friendly' name of the page). If I was to add a third '/' on the string I'd like this to become param3, etc, etc.
Ideally I'd like to be able to put this code somewhere that I could include it on whichever usercontrols I'd need it to work.
Uri.Segments maybe what you are looking for:
new Uri("http://www.contoso.com/foo/bar/index.htm#search").Segments
Results in [ "/", "foo/", "bar/", "index.html" ]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With