How should you complete the relevant code?

You are developing an application that will includea 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 first line of the response from theweb
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.)

You are developing an application that will includea 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 first line of the response from theweb
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.)

Answer:

Explanation:



Leave a Reply 3

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


MarcoJacob

MarcoJacob

private async void GetData(WebResponse response)
{
var streamReader = new StreamReader(response.GetResponseStream());

= await streamReader.ReadLineAsync();
}

Est

Est

Marco Jacob is right! ReadLineAsync is used to read a line of characters asynchronously from the current stream and returns the data as a string whereas ReadToEndAsync reads all characters from the current position to the end of the stream asynchronously and returns them as one string

Herman McConnell

Herman McConnell

private async void…

urlText.Text = await streamReader.ReadLineAsync();