GeoCoordinate.IsUnknown Property

Definition

Gets a value that indicates whether the GeoCoordinate does not contain latitude or longitude data.

C#
public bool IsUnknown { get; }

Property Value

true if the GeoCoordinate does not contain latitude or longitude data; otherwise, false.

Examples

The following code example verifies whether the GeoCoordinate that corresponds to a location is Unknown before printing out its latitude and longitude.

C#
using System;
using System.Device.Location;

namespace GetLocationPropertyHandleUnknown
{
    class Program
    {
        static void Main(string[] args)
        {
            GetLocationPropertyHandleUnknown();
        }

        static void GetLocationPropertyHandleUnknown()
        {
            GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();
            watcher.TryStart(false, TimeSpan.FromMilliseconds(1000));

            if (!watcher.Position.Location.IsUnknown)
            {
                GeoCoordinate coord = watcher.Position.Location;

                Console.WriteLine("Lat: {0}, Long: {1}",
                    coord.Latitude,
                    coord.Longitude);
            }
            else
            {
                Console.WriteLine("Unknown");
            }
        }
    }
}

Remarks

A GeoCoordinate that does not contain latitude or longitude data is equal to Unknown.

Applies to

Proizvod Verzije
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1