เมธอด Uri.IsWellFormedOriginalString() ใน C# บ่งชี้ว่าสตริงที่ใช้สร้าง Uri นี้เป็นรูปแบบที่ถูกต้องและไม่จำเป็นต้องทำการ escape เพิ่มเติม
ไวยากรณ์
public bool 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.tutorialspoint.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!");
}
}ผลลัพธ์
URI = https://www.tutorialspoint.com/index.htm URI = https://www.tutorialspoint.com/ Both the URIs aren't equal! newURI1 is well formed!