Hello Jon,
You can use a foreach statement:
Thanks for your reply, this helped me a lot. Is lot more simplier
MapPoint.Location loc = o as MapPoint.Location;
if (loc != null && loc.StreetAddress != null)
So I see, if o is not a Location object, then the 'o as' returns null. So
not needed to play around with exception blocks here. Nice
foreach (object o in objResults)
{
MapPoint.Location loc = o as MapPoint.Location;
I see this programming style often. I'm used to declare al local stack
variables in the beginning of a function. Is this way not setting up stack
frames over and over again in a loop, or is this no matter in NET ?
It would help if you'd give us a full program. Chances are you can just
use objResults[0] from C#, but as we don't know what objResults are
from your post, that's just a guess.
It is only a little experiment with Mappoint in C# to learn the IDE /
programming. I'm not new to programming but very new to NET. This is complete:
private void stratenToolStripMenuItem_Click(object sender, EventArgs
e)
{
MapPoint.Location objLoc;
MapPoint.Location Loc;
MapPoint.FindResults objResults;
MapPoint.Pushpin PP;
System.Collections.IEnumerator Result;
objLoc = MP.ActiveMap.GetLocation(Lat, Lon, Alt);
objLoc.GoTo();
// check if we are on a street
PP = MP.ActiveMap.AddPushpin(objLoc, "Kieken");
PP.Symbol = 1;
objResults =
MP.ActiveMap.ObjectsFromPoint(MP.ActiveMap.LocationToX(objLoc),
MP.ActiveMap.LocationToY(objLoc));
foreach (object o in objResults) {
Loc = o as MapPoint.Location;
if(Loc != null && Loc.StreetAddress != null)
Console.WriteLine("value " + Loc.StreetAddress.Value);
else
Console.WriteLine("--- not mappoint.location object ---");
}
}
thx, Wilfried
http://www.mestdagh.biz