Uri.CheckSchemeName(String)方法用于确定指定的方案名称是否有效。
Syntax: public static bool CheckSchemeName (string schemeName);
Here, it takes the scheme name to validate.
Return Value: This method returns a Boolean value true if the scheme name is valid otherwise, false.
下面的程序说明了Uri.CheckSchemeName()方法的用法:
范例1:
// C# program to demonstrate the
// Uri.CheckSchemeName(string) Method
using System;
using System.Globalization;
class GFG {
// Main Method
public static void Main()
{
// Declaring and initializing Uri
Uri uri = new Uri("http://www.geeksforgeeks.org");
// Determining the Scheme of the Uri
string scheme = uri.Scheme;
// using CheckSchemeName() method
bool value = Uri.CheckSchemeName(scheme);
// Displaying the result
if (value)
Console.WriteLine("Scheme name is valid");
else
Console.WriteLine("Scheme name is invalid");
}
}
输出:
Scheme name is valid
范例2:
// C# program to demonstrate the
// Uri.CheckSchemeName(string) Method
using System;
using System.Globalization;
class GFG {
// Main Method
public static void Main()
{
// Declaring and initializing Uri
Uri uri = new Uri("https://www.pierobon.org/iis/review1.htm.html#one");
// Determining the Scheme of the Uri
string scheme = uri.Scheme;
// using CheckSchemeName() method
bool value = Uri.CheckSchemeName(scheme);
// Displaying the result
if (value)
Console.WriteLine("Scheme name is valid");
else
Console.WriteLine("Scheme name is invalid");
}
}
输出:
Scheme name is valid
参考:
- https://docs.microsoft.com/zh-cn/dotnet/api/system.uri.checkschemename?view=netstandard-2.1