private string getHtml(string url) 
    {         WebClient myWebClient = new WebClient(); 
        byte[] myDataBuffer = myWebClient.DownloadData(url); 
        return Encoding.Default.GetString(myDataBuffer);     }编译器错误信息: CS0103: 当前上下文中不存在名称“Encoding

解决方案 »

  1.   

    using System.Text;orSystem.Text.Encoding
      

  2.   

    or System.Text.Encoding.GetString(myDataBuffer); 
      

  3.   

    using System.Text; or System.Text.Encoding
      

  4.   

        private string getHtml(string url) 
        {         WebClient myWebClient = new WebClient(); 
            byte[] myDataBuffer = myWebClient.DownloadData(url); 
            return System.Text.Encoding.Default.GetString(myDataBuffer);     } 
      

  5.   

    添加System.Text引用
    USING System.Text
      

  6.   

    少了命名空间
    两种方法
    1 添加using System.Text
    2 把Encoding改成System.Text.Encoding
      

  7.   

    我这样调用这么没看到数据呢?<asp:Label ID="mrns" runat="server" Text='<%# getHtml("tqyb.asp") %>'></asp:Label>
      

  8.   

    <asp:Label ID="mrns" runat="server" Text=' <%= getHtml("tqyb.asp") %>'> </asp:Label>