我正在处理每日股票市场数据的记忆xml,并且我获得了其中一个日期的值“8/221/19055”。我看到TryParse很可能是我检查有效日期的最佳选择,但MSDN文档似乎对第二个参数“out DateTime结果”的解释很轻。我如何在下面的linq查询中使用它?如何在xml数据的linq查询中使用TryParse?
var makeInfo =
from s in doc.Descendants("quote")
where s.Element("LastTradeDate") != null
&& s.Attribute("symbol") != null
let dateStr = s.Element("LastTradeDate").Value
where !string.IsNullOrEmpty(dateStr)
&& DateTime.Parse(dateStr, enUS) == targetDate
select new DailyPricingVolDP((string)s.Attribute("symbol"),
(DateTime)s.Element("LastTradeDate"),
(double)s.Element("Open"),
(double)s.Element("DaysHigh"),
(double)s.Element("DaysLow"),
(double)s.Element("LastTradePriceOnly"),
(long)s.Element("Volume"));
有你试着将输出保存到一个变量中,然后比较urlinq中的两个日期到xml – Boomer
@Boomer谢谢,它看起来像(或某种形式的逻辑)将是解决方案,现在通过这些.. – StatsViaCsh