DownloadStringCompletedEventArgs.Result プロパティ

定義

DownloadStringAsync メソッドによってダウンロードされたデータを取得します。

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

プロパティ値

ダウンロードされたデータが格納されている String

次のコード例では、このプロパティの値を表示します。

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

注釈

このプロパティによって返されるデータを使用するError前に、 プロパティと Cancelled プロパティをチェックする必要があります。 プロパティの Error 値が Exception オブジェクトであるか、プロパティ Cancelled の値が の場合、 true非同期操作は正しく完了せず、 Result プロパティの値は無効になります。

適用対象