I Have this error message :
Possible unitended reference comparison; to get a value coparison, cast the left hand side to type string
problem :
((Pushpin)p).Tag == "locationPushpin"));
============================
double Dlat = Convert.ToDouble(g_strLat);
double Dlon = Convert.ToDouble(g_strLon);
this.map1.Center = new GeoCoordinate(Dlat, Dlon);
if (this.map1.Children.Count != 0)
{
var pushpin = map1.Children.FirstOrDefault(p => (p.GetType() == typeof(Pushpin) && ((Pushpin)p).Tag == "locationPushpin"));
if (pushpin != null)
{
this.map1.Children.Remove(pushpin);
}
}
Pushpin locationPushpin = new Pushpin();
//---set the location for the pushpin---
locationPushpin.Tag = "locationPushpin";
locationPushpin.Location = new GeoCoordinate(Dlat, Dlon);
locationPushpin.Content = new Ellipse()
{
Fill = new SolidColorBrush(Colors.Orange),
//Opacity = .8,
Height = 40,
Width = 30
};
locationPushpin.Width = 60;
locationPushpin.Height = 100;
this.map1.Center = new GeoCoordinate(Dlat, Dlon);
this.map1.Children.Add(locationPushpin);
this.map1.ZoomLevel = 13;
Would appreciate your help. Thanks
Firstly, your query would only find exact objects of type
Pushpin. This is cleaner:The next problem is that
Tagis of typeobject. So you really want:Otherwise you’ll be doing a reference comparison between the
Tagvalue and the string. So you could have equal but distinct strings, and the pushpin wouldn’t be found.