Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

CivicAddress.IsUnknown Property

.NET Framework 4.6 and 4.5

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

Supported in: 4.6, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft