저는 Asp.Net 2.0을 사용하고 있습니다. Store Locator ASP.NET Application Using Google Maps API을 빌드하는 방법에 대한 응용 프로그램을 만들려고했습니다. "var "오류가 발생했습니다."형식 또는 네임 스페이스 이름 'var'을 찾을 수 없습니다 (사용 지시문이나 어셈블리 참조가 누락 되었습니까?) ".형식 또는 네임 스페이스 이름 'var'을 asp.net 2.0에서 찾을 수 없습니다.
위의 기사를 다운로드했으며 vs2005.I에서 올바르게 작업하고 있습니다. 왜 오류가 내 프로젝트에서만 발생하는지 궁금합니다.
네임 스페이스는 내가 응용 프로그램을 Heres 클래스 내가
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;
}
을 사용했다
using System;
using System.Collections.Generic;
using System.Web;
using System.Xml.Linq;
using System.Linq;
에 사용한
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'
var는 C# 3.0까지 도입되지 않았습니다. http://msdn.microsoft.com/en-us/library/bb383973.aspx – Ricky