DownloadStringCompletedEventArgs.Result 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得透過某種 DownloadStringAsync 方法下載的資料。
public:
property System::String ^ Result { System::String ^ get(); };
public string Result { get; }
member this.Result : string
Public ReadOnly Property Result As String
屬性值
String A 裡面包含下載的資料。
範例
以下程式碼範例顯示此屬性的值。
private static void DownloadStringCallback2(Object sender, DownloadStringCompletedEventArgs e)
{
// If the request was not canceled and did not throw
// an exception, display the resource.
if (!e.Cancelled && e.Error == null)
{
string textString = (string)e.Result;
Console.WriteLine(textString);
}
}
Private Shared Sub DownloadStringCallback2(ByVal sender As Object, ByVal e As DownloadStringCompletedEventArgs)
' If the request was not canceled and did not throw
' an exception, display the resource.
If e.Cancelled = False AndAlso e.Error Is Nothing Then
Dim textString As String = CStr(e.Result)
Console.WriteLine(textString)
End If
End Sub
備註
你應該先檢查 Error 和 Cancelled 屬性,再使用這個屬性回傳的資料。 若屬性的值為Exception物件或Cancelled屬性值為 true,則Error非同步操作未正確完成,屬性Result值將不成立。