AspBucket offers ASP.NET, C#, VB, Jquery, CSS, Ajax, SQL tutorials. It is the best place for programmers to learn

Wednesday, 4 November 2015

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

  • Popular Posts
  • Comments