【发布时间】:2013-04-04 22:25:40
【问题描述】:
在我正在解析的 XML 中,我有以下内容:
<event>
<book>Felicity Fly</book>
<author>Christina Gabbitas</author>
<bookImgUrl>http://www.whsmith.co.uk/Images/Products\957\255\9780957255203_t_f.jpg</bookImgUrl>
<info>Christina Gabbitas will be signing copies of her new book, Felicity Fly. Books should be bought from WHSmith. Proof of purchase may be necessary</info>
<date>20 Apr 2013</date>
<startTime>10:30</startTime>
<location>
<name>WHSmith Chester</name>
<address>5-7 Foregate Street</address>
<city>Chester</city>
<county>Cheshire</county>
<postcode>CH1 1HH</postcode>
<tel>01244 321106</tel>
</location>
</event>
我想从 date> 和 <startTime> 两个节点创建一个 DateTime 对象。所以我这样做:
var EventEntity = new Event()
{
Book = e.Book,
BookImgUrl = e.BookImgUrl,
Info = e.Info,
Start = new DateTime().**?**
};
但是当我在 DateTime 对象后按点 [.] 时,我没有从 Intellisense 获取 Parse 方法,这是为什么呢?我做错了什么?
我正计划使用this post 中概述的解决方案。
【问题讨论】:
标签: string parsing c#-4.0 datetime