Uri.CheckSchemeName(String) Uri.CheckSchemeName(String) Uri.CheckSchemeName(String) Uri.CheckSchemeName(String) Method


确定指定的方案名是否有效。Determines whether the specified scheme name is valid.

 static bool CheckSchemeName(System::String ^ schemeName);
public static bool CheckSchemeName (string schemeName);
static member CheckSchemeName : string -> bool
Public Shared Function CheckSchemeName (schemeName As String) As Boolean


String String String String

要验证的方案名。The scheme name to validate.


一个 Boolean 值。如果方案名有效,则该值为 true;否则为 falseA Boolean value that is true if the scheme name is valid; otherwise, false.


下面的示例创建Uri实例,并检查的方案名称是否有效。The following example creates a Uri instance and checks whether the scheme name is valid.

Uri^ address1 = gcnew Uri( "http://www.contoso.com/index.htm#search" );
Console::WriteLine( "address 1 {0} a valid scheme name",
   Uri::CheckSchemeName( address1->Scheme ) ? (String^)" has" : " does not have" );
if ( address1->Scheme == Uri::UriSchemeHttp )
   Console::WriteLine( "Uri is HTTP type" );

Console::WriteLine( address1->HostNameType );
Uri address1 = new Uri("http://www.contoso.com/index.htm#search");
Console.WriteLine("address 1 {0} a valid scheme name",
      Uri.CheckSchemeName(address1.Scheme) ? " has" : " does not have");

if (address1.Scheme == Uri.UriSchemeHttp)
    Console.WriteLine("Uri is HTTP type");
Dim address1 As New Uri("http://www.contoso.com/index.htm#search")
Console.WriteLine("address 1 {0} a valid scheme name", IIf(Uri.CheckSchemeName(address1.Scheme), " has", " does not have")) 'TODO: For performance reasons this should be changed to nested IF statements

If address1.Scheme = Uri.UriSchemeHttp Then
    Console.WriteLine("Uri is HTTP type")
End If 


此方法检查默认情况下根据 RFC 2396 有效性的方案名称。This method checks the scheme name for validity according to RFC 2396 by default. 如果启用了国际资源标识符 (Iri) 或国际化域名 (IDN) 分析,此方法将检查根据 RFC 3986 的有效性的方案名称。If International Resource Identifiers (IRIs) or Internationalized Domain Name (IDN) parsing is enabled, this method checks the scheme name for validity according to RFC 3986. 方案名称必须以字母开头,并且必须包含字母、 数字和字符"。","+"或"-"。The scheme name must begin with a letter and must contain only letters, digits, and the characters ".", "+", or "-".

IRI 支持的详细信息,请参阅备注部分Uri类。For more information on IRI support, see the Remarks section for the Uri class.