Uri.CheckSchemeName(String) Metodo

Definizione

Determina se il nome dello schema specificato è valido.

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

Parametri

schemeName
String

Nome dello schema da convalidare.

Restituisce

Boolean

true se il nome dello schema è valido; in caso contrario, false.

Esempio

L'esempio seguente crea un'istanza Uri e verifica se il nome dello schema è valido.

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");

Console.WriteLine(address1.HostNameType);
let address1 = Uri "http://www.contoso.com/index.htm#search"
printfn $"""address 1 {if Uri.CheckSchemeName address1.Scheme then " has" else " does not have"} a valid scheme name"""

if address1.Scheme = Uri.UriSchemeHttp then
    printfn "Uri is HTTP type"

printfn $"{address1.HostNameType}"
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 
Console.WriteLine(address1.HostNameType)

Commenti

Questo metodo controlla il nome dello schema per la validità in base a RFC 2396 per impostazione predefinita. Se l'analisi di IDN (International Resource Identifiers) o Internationalized Domain Name (IDN) è abilitata, questo metodo controlla il nome dello schema per la validità in base a RFC 3986. Il nome dello schema deve iniziare con una lettera e deve contenere solo lettere, cifre e caratteri ".", "+", o "-".

Per altre informazioni sul supporto IRI, vedere la sezione Osservazioni per la Uri classe.

Si applica a