GeoCoordinate.Unknown 欄位
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
表示含有不明緯度及經度欄位的 GeoCoordinate 物件。
public: static initonly System::Device::Location::GeoCoordinate ^ Unknown;
C#
public static readonly System.Device.Location.GeoCoordinate Unknown;
staticval mutable Unknown : System.Device.Location.GeoCoordinate
Public Shared ReadOnly Unknown As GeoCoordinate
下列程式代碼範例會驗證對應至位置的 是否 GeoCoordinate 在 Unknown 列印出其緯度和經度之前。
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 != 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
屬性 IsUnknown 可用來驗證 是否 GeoCoordinate 不包含任何數據。
產品 | 版本 |
---|---|
.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 |