共用方式為


GeoCoordinate.Speed 屬性

定義

取得或設定每秒的速度 (以公尺為單位)。

public:
 property double Speed { double get(); void set(double value); };
public double Speed { get; set; }
member this.Speed : double with get, set
Public Property Speed As Double

屬性值

每秒的速度 (以公尺為單位)。 這個速度必須大於或等於零,或是 NaN

例外狀況

Speed 是在值範圍以外設定的。

範例

下列範例會Course列印目前位置 的 GeoCoordinateSpeed 屬性。

static void GetLocationCourseAndSpeed()
{
    GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();

    watcher.TryStart(true, TimeSpan.FromMilliseconds(1000));

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

        Console.WriteLine("Course: {0}, Speed: {1}",
            coord.Course,
            coord.Speed);
    }
    else
    {
        Console.WriteLine("Unknown");
    }
}

Public Sub GetLocationCourseAndSpeed()
    Dim watcher As GeoCoordinateWatcher
    watcher = New System.Device.Location.GeoCoordinateWatcher()
    watcher.TryStart(False, TimeSpan.FromMilliseconds(1000))

    If Not watcher.Position.Location.IsUnknown Then
        Dim coord As GeoCoordinate = watcher.Position.Location
        Console.WriteLine("Course: {0}, Speed: {1}",
            coord.Course,
            coord.Speed) 'NaN if not available.
    Else
        Console.WriteLine("Location unknown.")
    End If

End Sub

適用於