Uri.ToString Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Belirtilen Uri örnek için kurallı dize gösterimini alır.
public:
override System::String ^ ToString();
public override string ToString();
override this.ToString : unit -> string
Public Overrides Function ToString () As String
Döndürülenler
Örneğin ayarlanmamış kurallı gösterimi Uri . #, ?ve %dışında tüm karakterlerin düzeni kaldırılmıştır.
Örnekler
Aşağıdaki örnek bir dizeden yeni Uri bir örnek oluşturur. oluşturucuya geçirilen dizeyi döndüren ve dizenin kurallı biçimini döndüren öğesine yapılan çağrıdan OriginalStringdöndürülen ToStringdeğer arasındaki farkı gösterir.
// Create a new Uri from a string address.
Uri uriAddress = new Uri("HTTP://www.Contoso.com:80/thick%20and%20thin.htm");
// Write the new Uri to the console and note the difference in the two values.
// ToString() gives the canonical version. OriginalString gives the orginal
// string that was passed to the constructor.
// The following outputs "http://www.contoso.com/thick and thin.htm".
Console.WriteLine(uriAddress.ToString());
// The following outputs "HTTP://www.Contoso.com:80/thick%20and%20thin.htm".
Console.WriteLine(uriAddress.OriginalString);
// Create a new Uri from a string address.
let uriAddress = Uri "HTTP://www.Contoso.com:80/thick%20and%20thin.htm"
// Write the new Uri to the console and note the difference in the two values.
// ToString() gives the canonical version. OriginalString gives the orginal
// string that was passed to the constructor.
// The following outputs "http://www.contoso.com/thick and thin.htm".
printfn $"{uriAddress.ToString()}"
// The following outputs "HTTP://www.Contoso.com:80/thick%20and%20thin.htm".
printfn $"{uriAddress.OriginalString}"
' Create a new Uri from a string address.
Dim uriAddress As New Uri("HTTP://www.Contoso.com:80/thick%20and%20thin.htm")
' Write the new Uri to the console and note the difference in the two values.
' ToString() gives the canonical version. OriginalString gives the orginal
' string that was passed to the constructor.
' The following outputs "http://www.contoso.com/thick and thin.htm".
Console.WriteLine(uriAddress.ToString())
' The following outputs "HTTP://www.Contoso.com:80/thick%20and%20thin.htm".
Console.WriteLine(uriAddress.OriginalString)
End Sub
Açıklamalar
Bu yöntem tarafından döndürülen dize, bağlantı noktası şema için varsayılan bağlantı noktası olduğunda bağlantı noktası bilgilerini içermez.
Note
yöntemi tarafından ToString döndürülen dize, konsol uygulamasının durumunu bozabilecek denetim karakterleri içerebilir. Döndürülen dizeden denetim karakterlerini kaldırmak için biçimiyle GetComponents yöntemini kullanabilirsinizUriFormat.SafeUnescaped.