共用方式為


GeoCoordinate.IsUnknown 屬性

定義

取得值,這個值表示 GeoCoordinate 是否不含緯度或經度資料。

public:
 property bool IsUnknown { bool get(); };
public bool IsUnknown { get; }
member this.IsUnknown : bool
Public ReadOnly Property IsUnknown As Boolean

屬性值

如果 GeoCoordinate 不含緯度或經度資料,則為 true,否則為 false

範例

下列程式代碼範例會驗證對應至位置的 是否 GeoCoordinateUnknown 列印出其緯度和經度之前。

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 != true)
            {
                GeoCoordinate coord = watcher.Position.Location;

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

Module GetLocationProperty
    Public Sub GetLocationPropertyHandleUnknown()
        Dim watcher As New System.Device.Location.GeoCoordinateWatcher()
        watcher.TryStart(False, TimeSpan.FromMilliseconds(1000))
        If watcher.Position.Location.IsUnknown <> True Then
            Dim coord As GeoCoordinate = watcher.Position.Location
            Console.WriteLine("Lat: {0}, Long: {1}", coord.Latitude, coord.Longitude)
        Else
            Console.WriteLine("Unknown latitude and longitude.")
        End If
    End Sub

    Public Sub Main()
        GetLocationPropertyHandleUnknown()
        Console.ReadLine()
    End Sub

End Module

備註

GeoCoordinate不包含緯度或經度資料的 ,等於 Unknown

適用於