我正在尝试将格式为“2012年8月”的字符串解析为DateTime对象。该字符串来自DataTable中的列名称。使用TryParseExact将“2012年8月”转换为DateTime对象
string columnName= row[col].ToString(); // "August 2012"
起初我尝试使用DateTime.TryParse()...
bool result = DateTime.TryParse(row[col].ToString, out convertedDateTime);
但它一直返回false。所以下次我试着用DateTime.TryParseExact使用正确的cultureformat描述here ...
CultureInfo enUS = new CultureInfo("af-ZA");
DateTime.TryParseExact(row[col].ToString(), "y", enUS, DateTimeStyles.None, out columnNameAsDate)
然而,这回头率假也。我究竟做错了什么?我不应该能够将格式为2012年8月的字符串解析为DateTime对象吗?