Linq 类型或命名空间名称';var';在asp.net 2.0中找不到

Linq 类型或命名空间名称';var';在asp.net 2.0中找不到,linq,visual-studio-2005,asp.net-2.0,Linq,Visual Studio 2005,Asp.net 2.0,我正在使用Asp.Net 2.0。我试图构建一个关于如何构建的应用程序。当我试图在应用程序中使用“var”时,它给出了错误“找不到类型或命名空间名称“var”(是否缺少using指令或程序集引用?) 我已经下载了上面的文章,并且在vs2005中工作正常。我想知道为什么错误只出现在我的项目中 我在应用程序中使用的名称空间 using System; using System.Collections.Generic; using System.Web; using System.Xml.Linq;

我正在使用Asp.Net 2.0。我试图构建一个关于如何构建的应用程序。当我试图在应用程序中使用“var”时,它给出了错误“找不到类型或命名空间名称“var”(是否缺少using指令或程序集引用?)

我已经下载了上面的文章,并且在vs2005中工作正常。我想知道为什么错误只出现在我的项目中

我在应用程序中使用的名称空间

using System;
using System.Collections.Generic;
using System.Web;
using System.Xml.Linq;
using System.Linq;
这是我上过的课

public static XElement GetGeocodingSearchResults(string address)
{
    // Use the Google Geocoding service to get information about the user-entered address
    // See http://code.google.com/apis/maps/documentation/geocoding/index.html for more info...
    var url = String.Format("http://maps.google.com/maps/api/geocode/xml?address={0}&sensor=false", HttpContext.Current.Server.UrlEncode(address));

    // Load the XML into an XElement object (whee, LINQ to XML!)
    var results = XElement.Load(url);

    // Check the status
    var status = results.Element("status").Value;
    if (status != "OK" && status != "ZERO_RESULTS")
        // Whoops, something else was wrong with the request...
        throw new ApplicationException("There was an error with Google's Geocoding Service: " + status);

    return results;
}
我得到的错误如下

Error 1 : The type or namespace name 'var' could not be found (are you missing a using directive or an assembly reference?)

Error 2 : The best overloaded method match for 'System.Xml.Linq.XElement.Load(string)' has some invalid arguments

Error 3:cannot convert from 'var' to 'string'
关键字在.NET2.0(C#2.0)中不可用


它仅在C#3.0及以上版本中提供。这是C#语言特性,在旧版本中不可用。

var直到C#3.0才引入。我已经在我的web.config中下载并安装了.net3.5 framework。它会有什么不同吗?我还下载了上述应用程序中提供的代码,它工作得非常好。。