Uri.IsWellFormedOriginalString() Method in C#


The Uri.IsWellFormedOriginalString() method in C# indicates whether the string used to construct this Uri was well-formed and is not required to be further escaped.

Syntax

Following is the syntax −

public bool IsWellFormedOriginalString ();

Example

Let us now see an example to implement the Uri.IsWellFormedOriginalString() method −

using System;
public class Demo {
   public static void Main(){
      Uri newURI1 = new Uri("https://www.tutorialspoint.com/index.htm");
      Console.WriteLine("URI = "+newURI1);
      Uri newURI2 = new Uri("https://www.qries.com/");
      Console.WriteLine("URI = "+newURI2);
      if(newURI1.Equals(newURI2))
         Console.WriteLine("Both the URIs are equal!");
      else
         Console.WriteLine("Both the URIs aren't equal!");
      if(newURI1.IsWellFormedOriginalString())
         Console.WriteLine("newURI1 is well formed!");
      else
         Console.WriteLine("newURI1 isn't well formed!");
   }
}

Output

This will produce the following output −

URI = https://www.tutorialspoint.com/index.htm
URI = https://www.tutorialspoint.com/
Both the URIs aren't equal!
newURI1 is well formed!

Updated on: 14-Nov-2019

20 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements