'对象'不包含' ToDateTime'的定义

时间:2016-02-26 14:12:19

标签: c# datetime

我正在编写一个从字段中获取数据的脚本。我想将它们转换为DateTime。这是代码:

Document.Field("Document Section 1\\Verification Date").Value.ParseExact();

Document.Field("Document Section 1\\Verification Date").Value.ParseExact();

我已尝试ParseExactToDateTimeTryParse,每次错误都相同。

  

'对象'不包含' ParseExact'

的定义

我不是C#摇滚明星,所以如果你向我展示正确的方式,我将不胜感激,不仅是非常的,而是代码。

1 个答案:

答案 0 :(得分:2)

我不知道价值是什么,但

Document.Field("Document Section 1\\Verification Date").Value

将返回object

你需要的是一个字符串。然后可以将此字符串解析为DateTime
所以解决方案就是

DateTime.Parse(((String)Document.Field("Document Section 1\\Verification Date").Value)

旁注:DateTime.Parse是否也不接受object

相关问题