Computer >> Máy Tính >  >> Lập trình >> C#

Phương thức Uri.IsWellFormedOriginalString () trong C #

Phương thức Uri.IsWellFormedOriginalString () trong C # cho biết liệu chuỗi được sử dụng để xây dựng Uri này có được định dạng tốt hay không và không cần phải thoát thêm.

Cú pháp

Sau đây là cú pháp -

public bool IsWellFormedOriginalString ();

Ví dụ

Bây giờ chúng ta hãy xem một ví dụ để triển khai phương thức Uri.IsWellFormedOriginalString () -

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!");
   }
}

Đầu ra

Điều này sẽ tạo ra kết quả sau -

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