我正在尝试以字符串格式转换包含日期的字符串数组
private string[] ex = new string[]{
"29-06-2017","29-12-2016","30-06-2016","31-12-2015","25-06-2015","24-12-2014","26-06-2014","26-12-2013"};
我想转换为十进制数组,我使用了下面的代码,但它不起作用。
public void load()
{
DateTime[] exDate=Array.ConvertAll(ex, new Converter<string, DateTime>(convertDecimal));
List<DateTime> expiryDate = new List<DateTime>();
expiryDate.AddRange(exDate);
expiryDate.Sort();
_expiryDate=expiryDate;
}
public static DateTime convertDecimal(string strgDate)
{
return DateTime.Parse(strgDate);
}
我得到的错误是:
"String was not recognized as a valid DateTime."