Download file from URL to a string

How could I use C# to download the contents of a URL, and store the text in a string, without having to save the file to the hard drive?


Solution 1:

string contents;
using (var wc = new System.Net.WebClient())
    contents = wc.DownloadString(url);

Solution 2:

Use a WebClient

var result = string.Empty;
using (var webClient = new System.Net.WebClient())
{
    result = webClient.DownloadString("http://some.url");
}