views:

49

answers:

3

this code returns an empty string. What can I do to return something please?

CivicAddressResolver civicResolver = new CivicAddressResolver();
CivicAddress c = civicResolver.ResolveAddress(new GeoCoordinate(39,77));
textBlock1.Text = c.City;
A: 

There really isn't enough information here to comment anything. We need to know what ResolveAddress does. What do you want it to return? It seems like whatever you are doing can't find the long/lat (I assume) you are sending in.

Depending on what you want to do, you should return a null CivicAddress if it can't find the CivicAddress you are looking for and then do a null check before assigning o the textBlock1 control.

Wil
However it's strange, both `CivicAddress` and `CivicAddressResolver` are framework classes…
Ondrej Tucny
+3  A: 

The MSDN documentation for CivicAddressResolver.ResolveAddress() suggests that checking c.IsUnknown before trying to access c.City would be a good idea.

Mike Chess
I know that, but I want to return something. By adding this, I would only restrict even more =u
Alan
You want to return an address when the method probably didn't return one in the first place? It would seem like you need a default address that can be returned when CivicAddressResolver is unable to resolve the coordinates you supplied. If that's the case, checking IsUnknown is still the right way to handle the situation. (A default could be <unknown city> .)
Mike Chess
+1  A: 

From the MSDN docs (phone specific version):

This method is not implemented in the current release.

I would think that this is why you are not getting a result on Windows Phone 7.
Hopefully this functionality will be available soon. (And preferably via an OTA update.)

If you are not doing this on the phone please retag this question appropriately.

Matt Lacey