2010-12-19 23 views
0

我有以下片段,我試圖輸出一個特定的網站的HTML到控制檯。HTML不顯示在控制檯使用Webclient

using System; 
using System.Net; 

namespace googleHTML 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 

      WebClient client = new WebClient(); 

      string htmlCode = client.DownloadString("http://www.google.com"); 

      Console.ReadLine(); 
     } 
    } 
} 

當我在控制檯中運行它時,什麼都沒有發生?

謝謝。

回答

1
Console.Write(htmlCode); 

Console.ReadLine讀取一行從控制檯流中的文本輸入

1

你不會對html做任何事情,你只是在存儲它。

嘗試

Console.WriteLine(htmlCode); 

string htmlCode = client.DownloadString..