CivicAddress.IsUnknown Property

.NET Framework (current version)
 

Gets a value that indicates whether the CivicAddress contains data.

Namespace:   System.Device.Location
Assembly:  System.Device (in System.Device.dll)

public bool IsUnknown { get; }

Property Value

Type: System.Boolean

true if the CivicAddress is equal to Unknown; otherwise, false.

The following example uses IsUnknown to check the CivicAddress that is returned from ResolveAddress before the civic address is printed out.

static void ResolveAddressSync()
{
    GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
    watcher.MovementThreshold = 1.0; // set to one meter
    watcher.TryStart(false, TimeSpan.FromMilliseconds(1000));

    CivicAddressResolver resolver = new CivicAddressResolver();

    if (watcher.Position.Location.IsUnknown == false)
    {
        CivicAddress address = resolver.ResolveAddress(watcher.Position.Location);

        if (!address.IsUnknown)
        {
            Console.WriteLine("Country: {0}, Zip: {1}",
                    address.CountryRegion,
                    address.PostalCode);
        }
        else
        {
            Console.WriteLine("Address unknown.");
        }
    }
}

.NET Framework
Available since 4.0
Windows Phone Silverlight
Available since 7.0
Return to top
Show: