gpt4 book ai didi

c# - "..."的最佳重载匹配有一些无效参数

转载 作者:太空宇宙 更新时间:2023-11-03 21:44:10 25 4
gpt4 key购买 nike

我正在编写一个需要保存一些坐标(纬度和经度值)的程序。写入这些值似乎不是问题,只是当我加载它们并将 map 图钉应用于加载的坐标时。这是我用来加载的代码:

        try
{
//Read the file from the specified location.
fileReader = new StreamReader(new IsolatedStorageFileStream("cords.txt", FileMode.Open, fileStorage));
//Read the contents of the file (the only line we created).
string cords = fileReader.ReadToEnd();


Pushpin car = new Pushpin();
car.Background = new SolidColorBrush(Colors.Green);
car.Foreground = new SolidColorBrush(Colors.Black);
car.Content = "You Parked Here";
car.Tag = "carPushpin";
car.Location = cords; //getting error here...
this.map.Children.Add(car);
this.map.SetView(cords, 18.0); // ...and here

//Write the contents of the file to the TextBlock on the page.
fileReader.Close();
}
catch
{
MessageBox.Show("Debug Errror-no cords.txt");
}

以及我遇到的错误:

Cannot implicitly convert type 'string' to 'System.Device.Location.GeoCoordinate'

The best overloaded method match for 'Microsoft.Phone.Controls.Maps.Core.MapBase.SetView(System.Device.Location.GeoCoordinate, double)' has some invalid arguments

Argument 1: cannot convert from 'string' to 'System.Device.Location.GeoCoordinate'

希望大家帮帮我


我已尽我所能编辑我的代码,但仍然无法解决问题...修改后的代码:

        try
{
//Read the file from the specified location.
fileReader = new StreamReader(new IsolatedStorageFileStream("latitude.txt", FileMode.Open, fileStorage));
//Read the contents of the file (the only line we created).
string carlatitude = fileReader.ReadToEnd();

fileReader = new StreamReader(new IsolatedStorageFileStream("longitude.txt", FileMode.Open, fileStorage));
//Read the contents of the file (the only line we created).
string carlongitude = fileReader.ReadToEnd();
fileReader.Close();

carlocation = new GeoCoordinate(carlatitude, carlongitude);

Pushpin car = new Pushpin();
car.Background = new SolidColorBrush(Colors.Green);
car.Foreground = new SolidColorBrush(Colors.Black);
car.Content = "You Parked Here";
car.Tag = "carPushpin";
car.Location = carlocation;
this.map.Children.Add(car);
this.map.SetView(watcher.Position.Location, 18.0);

}
catch
{
MessageBox.Show("Debug Errror-no cords.txt");
}

最佳答案

您需要将 coords 的字符串表示形式转换为 System.Device.Location.GeoCoordinate 并将其传递给 SetView 方法。

关于c# - "..."的最佳重载匹配有一些无效参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17889843/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com