Here is simple way to get file name or extension of the file at specified string.
you need to use System.IO namespace
string path = "http://revenmerchantservices.com/default.aspx";
string fileName = System.IO.Path.GetFileName(path));
To get extension you can use GetExtension function
Now, you learned this technique hope you will use it instead of writting your own logic.