Uri.GetLeftPart(UriPartial) Uri.GetLeftPart(UriPartial) Uri.GetLeftPart(UriPartial) Uri.GetLeftPart(UriPartial) Method

Definizione

Ottiene la parte specificata di un'istanza di Uri.Gets the specified portion of a Uri instance.

public:
 System::String ^ GetLeftPart(UriPartial part);
public string GetLeftPart (UriPartial part);
member this.GetLeftPart : UriPartial -> string
Public Function GetLeftPart (part As UriPartial) As String

Parametri

part
UriPartial UriPartial UriPartial UriPartial

Uno dei valori di UriPartial che specifica la fine della parte di URI da restituire.One of the UriPartial values that specifies the end of the URI portion to return.

Restituisce

Oggetto String contenente la parte specificata dell'istanza di Uri.A String that contains the specified portion of the Uri instance.

Eccezioni

L'istanza di Uri corrente non è un'istanza assoluta.The current Uri instance is not an absolute instance.

Il parametro part specificato non è valido.The specified part is not valid.

Esempi

L'esempio seguente crea un Uri dell'istanza e scrive il percorso nella console.The following example creates a Uri instance and writes the path to the console.

// Create Uri
Uri^ uriAddress = gcnew Uri( "http://www.contoso.com/index.htm#search" );
Console::WriteLine( uriAddress->Fragment );
Console::WriteLine( "Uri {0} the default port ", uriAddress->IsDefaultPort ? (String^)"uses" : "does not use" );

Console::WriteLine( "The path of this Uri is {0}", uriAddress->GetLeftPart( UriPartial::Path ) );
Console::WriteLine( "Hash code {0}", uriAddress->GetHashCode() );
// The example displays the following output:
//        #search
//        Uri uses the default port
//        The path of this Uri is http://www.contoso.com/index.htm
//        Hash code -988419291
// Create Uri
Uri uriAddress = new Uri("http://www.contoso.com/index.htm#search");
Console.WriteLine(uriAddress.Fragment);
Console.WriteLine("Uri {0} the default port ", uriAddress.IsDefaultPort ? "uses" : "does not use");
 
Console.WriteLine("The path of this Uri is {0}", uriAddress.GetLeftPart(UriPartial.Path));
Console.WriteLine("Hash code {0}", uriAddress.GetHashCode());
// The example displays the following output:
//        #search
//        Uri uses the default port
//        The path of this Uri is http://www.contoso.com/index.htm
//        Hash code -988419291
' Create Uri
Dim uriAddress As New Uri("http://www.contoso.com/index.htm#search")
Console.WriteLine(uriAddress.Fragment)
Console.WriteLine("Uri {0} the default port ", If(uriAddress.IsDefaultPort, "uses", "does not use")) 

Console.WriteLine("The path of this Uri is {0}", uriAddress.GetLeftPart(UriPartial.Path))
Console.WriteLine("Hash code {0}", uriAddress.GetHashCode())
' The example displays the following output:
'        #search
'        Uri uses the default port
'        The path of this Uri is http://www.contoso.com/index.htm
'        Hash code -988419291

Commenti

Il GetLeftPart metodo restituisce una stringa contenente la parte più a sinistra della stringa di URI, che termina con la parte specificata da part.The GetLeftPart method returns a string containing the leftmost portion of the URI string, ending with the portion specified by part.

GetLeftPart include i delimitatori nei casi seguenti:GetLeftPart includes delimiters in the following cases:

  • Scheme include il delimitatore di schema.Scheme includes the scheme delimiter.

  • Authority non include il delimitatore di percorso.Authority does not include the path delimiter.

  • Path sono inclusi i delimitatori nell'URI originale fino al delimitatore di frammento o query.Path includes any delimiters in the original URI up to the query or fragment delimiter.

  • Query include il Path, oltre alla query e il delimitatore.Query includes the Path, plus the query and its delimiter.

Gli esempi seguenti illustrano un URI e i risultati della chiamata al metodo GetLeftPart con Scheme, Authority, Path, o Query.The following examples show a URI and the results of calling GetLeftPart with Scheme, Authority, Path, or Query.

URIURI SchemeScheme AutoritàAuthority PathPath QueryQuery
http://www.contoso.com/index.htm?date=today http://http:// http://www.contoso.com http://www.contoso.com/index.htm http://www.contoso.com/index.htm?date=today
http://www.contoso.com/index.htm#main http://http:// http://www.contoso.com http://www.contoso.com/index.htm http://www.contoso.com/index.htm
mailto:user@contoso.com?subject=urimailto:user@contoso.com?subject=uri mailto:mailto: mailto:user@contoso.com mailto:user@contoso.com?subject=urimailto:user@contoso.com?subject=uri <nessuno><none>
nntp://news.contoso.com/123456@contoso.com nntp://nntp:// nntp://news.contoso.comnntp://news.contoso.com nntp://news.contoso.com/123456@contoso.com nntp://news.contoso.com/123456@contoso.com
news:123456@contoso.com Novità:news: news:123456@contoso.com news:123456@contoso.com <nessuno><none>
file://server/filename.extfile://server/filename.ext file://file:// file://serverfile://server file://server/filename.extfile://server/filename.ext file://server/filename.extfile://server/filename.ext

Si applica a