DownloadStringCompletedEventArgs.Result Proprietà

Definizione

Ottiene i dati scaricati da un metodo DownloadStringAsync.

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

Valore della proprietà

String

Oggetto String che contiene i dati scaricati.

Esempio

Nell'esempio di codice seguente viene visualizzato il valore di questa proprietà.

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

Commenti

È necessario controllare le proprietà e Cancelled prima di usare i Error dati restituiti da questa proprietà. Se il Error valore della proprietà è un Exception oggetto o Cancelled il valore della proprietà è true, l'operazione asincrona non è stata completata correttamente e il Result valore della proprietà non sarà valido.

Si applica a