加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 当前上下文中不存在名称“Console”在xamrian表单应用程序

发布时间:2020-12-15 20:50:34 所属栏目:百科 来源:网络整理
导读:我正在开发一个Xamrian Forms中的应用程序,需要从设备获取地理位置数据,然后将地理位置坐标放入forecast.io URL我正在使用James Montemagno的Geolocator插件,我正在使用读取的代码我建议,但是我得到以下错误4次: The name ‘Console’ does not exist in th
我正在开发一个Xamrian Forms中的应用程序,需要从设备获取地理位置数据,然后将地理位置坐标放入forecast.io URL我正在使用James Montemagno的Geolocator插件,我正在使用读取的代码我建议,但是我得到以下错误4次:

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.有关我做错的任何想法?

解决方法

由于您的代码位于具有特定配置文件的PCL中,因此System.Console不可用.

使用Debug.WriteLine(“文本在这里”)代替,不要忘记使用System.Diagnostics;添加.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读