PrepAway - Latest Free Exam Questions & Answers

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.)

PrepAway - Latest Free Exam Questions & Answers

Answer:

Explanation:

3 Comments on “How should you complete the relevant code?

  1. MarcoJacob says:

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

    = await streamReader.ReadLineAsync();
    }




    5



    0
  2. Est says:

    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




    0



    0

Leave a Reply