[英]'object' does not contain a definition for 'ToDateTime'
我正在編寫一個腳本,該腳本從字段中獲取數據。 我想將它們轉換為DateTime
。 這是代碼:
Document.Field("Document Section 1\\Verification Date").Value.ParseExact();
和
Document.Field("Document Section 1\\Verification Date").Value.ParseExact();
我已經嘗試過ParseExact
, ToDateTime
, TryParse
,並且每次錯誤都是一樣的。
“對象”不包含“ ParseExact”的定義
我不是C#搖滾明星,因此,如果您以正確的方式,不僅在理論上而且在代碼方面向我展示正確的方法,我將不勝感激。
我不知道什么是價值,但是
Document.Field("Document Section 1\\Verification Date").Value
將返回一個object
。
您需要的是一個字符串。 然后可以將此字符串解析為DateTime
所以解決方案是
DateTime.Parse(((String)Document.Field("Document Section 1\\Verification Date").Value)
旁注: DateTime.Parse
也不接受object
嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.