Better way to validate URL in C# than try-catch
In this article i will discuss how to validate URL in c#. Most of developers are validate their urls by try-catch but this is not a good approach.So here i am going example to validate URL in C#.
string myString = "http//:google.com";
Uri myUri;
Uri.TryCreate(myString, UriKind.RelativeOrAbsolute, out myUri);
if (myUri.IsAbsoluteUri == false)
{
MessageBox.Show("Please Input Valid Feed Url");
}
0 comments :
Post a Comment