Uri.GetLeftPart(UriPartial) Yöntem
Tanım
public:
System::String ^ GetLeftPart(UriPartial part);
public string GetLeftPart (UriPartial part);
member this.GetLeftPart : UriPartial -> string
Public Function GetLeftPart (part As UriPartial) As String
Parametreler
- part
- UriPartial
Döndürülecek URI bölümünün sonunu belirten sabit listesi değerlerinden biri.One of the enumeration values that specifies the end of the URI portion to return.
Döndürülenler
Örneğin belirtilen bölümü Uri .The specified portion of the Uri instance.
Özel durumlar
Belirtilen part
geçerli değil.The specified part
is not valid.
Örnekler
Aşağıdaki örnek bir örnek oluşturur Uri ve konsola yolu yazar.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 output similar to the following:
// #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 output similar to the following:
// #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 output similar to the following:
' #search
' Uri uses the default port
' The path of this Uri is http://www.contoso.com/index.htm
' Hash code -988419291
Açıklamalar
GetLeftPartYöntemi, URI dizesinin en sol kısmını içeren ve tarafından belirtilen bölüm ile biten bir dize döndürür part
.The GetLeftPart method returns a string containing the leftmost portion of the URI string, ending with the portion specified by part
.
GetLeftPart Aşağıdaki durumlarda sınırlayıcıları içerir:GetLeftPart includes delimiters in the following cases:
Scheme şema sınırlayıcısı içerir.Scheme includes the scheme delimiter.
Authority yol sınırlayıcısı içermez.Authority does not include the path delimiter.
Path sorgu veya parça sınırlayıcısına kadar özgün URI 'deki sınırlayıcıları içerir.Path includes any delimiters in the original URI up to the query or fragment delimiter.
Query , ile Path sorguyu ve sınırlayıcıyı içerir.Query includes the Path, plus the query and its delimiter.
Aşağıdaki örneklerde,, veya ile çağırma sonuçları bir URI ve GetLeftPart ile Scheme gösterilmektedir Authority Path Query .The following examples show a URI and the results of calling GetLeftPart with Scheme, Authority, Path, or Query.
URIURI | DüzenScheme | YetkiliAuthority | YolPath | SorguQuery |
---|---|---|---|---|
http://www.contoso.com/index.htm?date=today |
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://www.contoso.com |
http://www.contoso.com/index.htm |
http://www.contoso.com/index.htm |
mailto:user@contoso.com?subject=uri |
mailto: |
mailto:user@contoso.com |
mailto:user@contoso.com?subject=uri |
<none> |
nntp://news.contoso.com/123456@contoso.com |
nntp:// |
nntp://news.contoso.com |
nntp://news.contoso.com/123456@contoso.com |
nntp://news.contoso.com/123456@contoso.com |
news:123456@contoso.com |
news: |
news:123456@contoso.com |
news:123456@contoso.com |
<none> |
file://server/filename.ext |
file:// |
file://server |
file://server/filename.ext |
file://server/filename.ext |