C# 错误CS0103:名称'HttpUtility';在当前上下文中不存在

C# 错误CS0103:名称'HttpUtility';在当前上下文中不存在,c#,mono,opensuse,C#,Mono,Opensuse,我收到以下错误“错误CS0103:名称`HttpUtility'在当前上下文中不存在” 当我尝试使用“$mcs file.cs”编译我的c#文件时。我添加了“usingsystem.Web”,并在SUSE12.1上使用mono框架运行它。我是C#的新手,在这里学习教程 这是my file.cs中的代码 using System; using System.Net; using System.Web; using System.Text; using System.Text.RegularExpr

我收到以下错误“错误CS0103:名称`HttpUtility'在当前上下文中不存在” 当我尝试使用“$mcs file.cs”编译我的c#文件时。我添加了“usingsystem.Web”,并在SUSE12.1上使用mono框架运行它。我是C#的新手,在这里学习教程

这是my file.cs中的代码

using System;
using System.Net;
using System.Web;
using System.Text;
using System.Text.RegularExpressions;

namespace Dela.Mono.Examples
{
        class GoogleSearch
         {
                static void Main(string[] args)
                 {
                        Console.Write("Please enter a string to search google for:");
                        string searchString = HttpUtility.UrlEncode(Console.ReadLine());

                        Console.WriteLine();
                        Console.Write("Please wait....\r");

                        //Query google
                        WebClient webClient = new WebClient();
                        byte[] response =     webClient.DownloadData("http://www.google.com/search?&num=5&q=" + searchString);


                        //Check reponse results
                        string regex = "g><a\\shref=\"?(?<URL>[^\">]*)[^>]*>(?<Name>[^<]*)";
                        MatchCollection matches = Regex.Matches(Encoding.ASCII.GetString(response), regex);

                        //output results
                        Console.WriteLine("===== Results =====");
                                 if(matches.Count > 0)
                                 {
                                        foreach(Match match in matches)
                                        {
                                                 Console.WriteLine(HttpUtility.HtmlDecode(
                                                        match.Groups["Name"].Value) +
                                                        " - " + match.Groups["URL"].Value);
                                        }
                                 }
                                 else
                                 {
                                        Console.WriteLine("0 results found");
                                 }
                } 
        }
}
使用系统;
Net系统;
使用System.Web;
使用系统文本;
使用System.Text.RegularExpressions;
名称空间Dela.Mono.Examples
{
类谷歌搜索
{
静态void Main(字符串[]参数)
{
Write(“请输入一个字符串以搜索google:”);
string searchString=HttpUtility.UrlEncode(Console.ReadLine());
Console.WriteLine();
控制台。写入(“请稍候…”\r);
//查询谷歌
WebClient WebClient=新的WebClient();
字节[]响应=webClient.DownloadData(“http://www.google.com/search?&num=5&q=“+搜索字符串);
//检查响应结果

string regex=“g>]*)[^>]*>(?[^如您链接到的文章中所述,请尝试使用以下工具进行编译:

$ mcs file.cs -r System.Web.dll

你的目标是客户端配置文件吗?试着改变它。是的,我是,系统似乎不可用。那么,考虑到我使用的是suse linux,我该如何处理它。是的,我正在尝试处理它。谢谢。@roykasa添加了
-r System.Web.dll
解决了你的问题吗?@NaceRedine请继续,并将其作为答案发布