How should you complete the relevant code?

DRAG DROP
You are developing an application that will include a method named GetData. The GetData() method will retrieve several lines of data from a web service by using a System.IO.StreamReader object.
You have the following requirements:
The GetData() method must return a string value that contains the entire response from the web service.
The application must remain responsive while the GetData() method runs.
You need to implement the GetData() method.
How should you complete the relevant code? (To answer, drag the appropriate objects to the correct locations in the answer area. Each object may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.)
Select and Place:


microsoft-exams

2 thoughts on “How should you complete the relevant code?

  1. I think must be:
    public async void GetData(WebResponse response) {
    string urlText;
    var sr = new StreamReader(response.GetResponseStream());
    urlText = await sr.ReadToEndAsync();
    }

  2. Second await cannot be applied, since first await awaits for string and string is not a Task. Error:
    CS1061 C# ‘string’ does not contain a definition for ‘GetAwaiter’ and no extension method ‘GetAwaiter’ accepting a first argument of type ‘string’ could be found.

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.