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