我試圖轉換包含字符串格式轉換串來串類型的日期時間「12-07-2012」
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."
@MarkByers 「字符串未被識別爲有效的DateTime」 – Vishwa