Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# C# Streams and Data Processing Streaming Data on the Net Become Zen

C# zenResponse Challenge Task 2

Please help. This is what it gives me: Bummer: Did you assign the return value of the 'DownloadString' method to the 'zenResponse' variable?

Program.cs
using System; 
using System.IO; 
using System.Net;

namespace Treehouse.CodeChallenges 
{ 
    class Program 
{ 
    static void Main(string[] args) 
    { 
        Console.WriteLine(BecomeZen()); 
          } 
        public static string BecomeZen() 
        { 
            string zenResponse = "";

        using(var webClient = new WebClient())
        {
        webClient.Headers.Add("User-Agent", "CodeChallenge");
        string response = webClient.DownloadString("https://api.github.com/zen");
        }

        return zenResponse;
    }
}
}

2 Answers

Steven Parker
Steven Parker
231,275 Points

The instructions say "Assign the result to the zenResponse variable.", but this code is assigning it to a new variable named "response" (which is then never used).

And happy holidays!   :christmas_tree:

Alright. Thanks.

Sure, I'll do so. Happy holidays to you too, Steven.