Phương thức Uri.CheckSchemeName () trong C # được sử dụng để xác định xem tên lược đồ đã chỉ định có hợp lệ hay không.
cú pháp
Sau đây là cú pháp -
public static bool CheckSchemeName (string schemeName);
Ở trên, tên lược đồ tham số là tên lược đồ cần xác thực.
Ví dụ
Bây giờ chúng ta hãy xem một ví dụ để triển khai phương thức Uri.CheckSchemeName () -
using System;
public class Demo {
public static void Main(){
Uri newURI = new Uri("https://www.tutorialspoint.com");
Console.WriteLine("URI = "+newURI);
string schemeName = newURI.Scheme;
if(Uri.CheckSchemeName(schemeName))
Console.WriteLine("Valid: Scheme name");
else
Console.WriteLine("Invalid: Scheme name");
}
} Đầu ra
Điều này sẽ tạo ra kết quả sau -
URI = https://www.tutorialspoint.com/ Valid: Scheme name
Ví dụ
Bây giờ chúng ta hãy xem một ví dụ khác để triển khai phương thức Uri.CheckSchemeName () -
using System;
public class Demo {
public static void Main(){
Uri newURI = new Uri("https://www.tutorialspoint.com/index.htm");
Console.WriteLine("URI = "+newURI);
string schemeName = newURI.Scheme;
if(Uri.CheckSchemeName(schemeName))
Console.WriteLine("Valid: Scheme name");
else
Console.WriteLine("Invalid: Scheme name");
}
} Đầu ra
Điều này sẽ tạo ra kết quả sau -
URI = https://www.tutorialspoint.com/index.htm Valid: Scheme name