你好,我在xamrian形成一個應用程序,需要從設備獲得的地理位置數據,然後把地理位置座標工作進入forecast.io網址我使用的由詹姆斯Montemagno的Geolocator插件,我使用的是閱讀我建議的代碼,但是我得到以下錯誤4次:「控制檯」的名稱並不在當前的背景下存在xamrian形式應用
The name 'Console' does not exist in the current context
這裏是我的代碼:
using AppName.Data;
using Xamarin.Forms;
using Plugin.Geolocator;
namespace AppName.Radar
{
public partial class RadarHome : ContentPage
{
public RadarHome()
{
var locator = CrossGeolocator.Current;
locator.DesiredAccuracy = 50;
var position = await locator.GetPositionAsync(timeout: 10000);
Console.WriteLine("Position Status: {0}", position.Timestamp);
Console.WriteLine("Position Latitude: {0}", position.Latitude);
Console.WriteLine("Position Longitude: {0}", position.Longitude);
var LatLong = position.Latitude + "," + position.Longitude;
var browser = new WebView();
browser.Source = "https://forecast.io/?mobile=1#/f/" + LatLong;
Content = browser;
}
}
}
我正在使用Visual Studio Update 3對我做錯了什麼想法?
感謝提前:)
那麼除了別的,如果你想使用'System.Console',你缺少一個'使用系統;'指令。但我不知道'System.Console'是否對於Xamarin Forms甚至是存在的...... –
您應該使用'Debug.WriteLine'來代替,因爲'System.Console'在PCL中不存在。類似於這個答案:http://stackoverflow.com/a/9675897/1048571/ http://brianlagunas.com/write-platform-specific-code-with-a-portable-class-library-pcl/ –