2013-04-01 3 views
1

저는 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' 
+0

var는 C# 3.0까지 도입되지 않았습니다. http://msdn.microsoft.com/en-us/library/bb383973.aspx – Ricky

답변

0

var 키워드가 아닌 다음과 같이 내가 점점 오전 오류는 .NET 2.0 (C# 2.0)에서 사용할 수 있습니다.

C# 3.0 이상에서만 사용할 수 있습니다. 이것은 C# 언어 기능이며 이전 버전에서는 사용할 수 없습니다.

+0

web.config에서 .net3.5 프레임 워크를 다운로드하여 설치했습니다. 차이가 있습니다. – Kannan

+0

또한 위의 응용 프로그램에 제공된 코드를 다운로드하여 완벽하게 작동합니다. – Kannan