我正在使用 Asp.Net 2.0。我正在尝试构建一个关于如何使用 Google Maps API 构建商店定位器 ASP.NET 应用程序的应用程序。当我尝试在应用程序中使用“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'