Bagikan melalui


DownloadStringCompletedEventArgs.Result Properti

Definisi

Mendapatkan data yang diunduh dengan DownloadStringAsync metode .

public:
 property System::String ^ Result { System::String ^ get(); };
public string Result { get; }
member this.Result : string
Public ReadOnly Property Result As String

Nilai Properti

String yang berisi data yang diunduh.

Contoh

Contoh kode berikut menampilkan nilai properti ini.

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 == nullptr )
   {
      String^ textString = dynamic_cast<String^>(e->Result);
      Console::WriteLine( textString );
   }
}
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

Keterangan

Anda harus memeriksa Error properti dan Cancelled sebelum menggunakan data yang dikembalikan oleh properti ini. Error Jika nilai properti adalah Exception objek atau Cancelled nilai properti adalah true, operasi asinkron tidak selesai dengan benar dan Result nilai properti tidak akan valid.

Berlaku untuk