Nyelv

DownloadStringCompletedEventArgs.Result Tulajdonság

Definíció

Lekéri a metódus által DownloadStringAsync letöltött adatokat.

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

Tulajdonság értéke

A String letöltött adatokat tartalmazó fájl.

Példák

Az alábbi példakód ennek a tulajdonságnak az értékét jeleníti meg.

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

Megjegyzések

A tulajdonság által visszaadott adatok használata előtt ellenőrizze a Error tulajdonságokat és Cancelled a tulajdonságokat. Ha a Error tulajdonság értéke objektum Exception vagy a Cancelled tulajdonság értéke true, az aszinkron művelet nem fejeződött be megfelelően, és a Result tulajdonság értéke érvénytelen lesz.

A következőre érvényes: