DownloadStringCompletedEventArgs.Result Propriété

Définition

Obtient les données qui sont téléchargées par une méthode DownloadStringAsync.

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

Valeur de propriété

String qui contient les données téléchargées.

Exemples

L’exemple de code suivant affiche la valeur de cette propriété.

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

Remarques

Vous devez case activée les Error propriétés et Cancelled avant d’utiliser les données retournées par cette propriété. Si la valeur de la Error propriété est un Exception objet ou si la valeur de la Cancelled propriété est , l’opération asynchrone ne s’est truepas terminée correctement et la valeur de la Result propriété ne sera pas valide.

S’applique à