語言

JsonElement.TryGetDateTime(DateTime) 方法

定義

嘗試將目前的 JSON 字串表示為 DateTime.

public:
 bool TryGetDateTime([Runtime::InteropServices::Out] DateTime % value);
public bool TryGetDateTime(out DateTime value);
member this.TryGetDateTime : DateTime -> bool
Public Function TryGetDateTime (ByRef value As DateTime) As Boolean

參數

value
DateTime

當此方法回傳時,包含與當前 JSON 字串相當的日期與時間值(若轉換成功,或 MinValue 若轉換失敗)。

傳回

true若字串可表示為DateTime;否則,。 false

例外狀況

這個值的 ValueKind 值不是 String。

父母 JsonDocument 已被處理掉。

備註

此方法僅建立符合 ISO 8601-1 擴展格式的 JSON 字串 DateTime 表示(參見 System.Text.JSON 中的 DateTime 與 DateTimeOffset 支援)。

適用於