LastsuccessfuldownloadDateTime

LastsuccessfuldownloadDateTime

我有以下非常不可靠的陈述:

  string LastsuccessfuldownloadDateTime = "04.07.2009 19:21:36"
  DateTime myDate = Convert.ToDateTime(LastsuccessfuldownloadDateTime);


是否可以在转换中明确显示日期和月份字段?
因为我的月和日字段正在交换...

谢谢

最佳答案

您可以使用DateTime.ParseExact():

// for European format (day followed by month)
DateTime myDate = DateTime.ParseExact(LastsuccessfuldownloadDateTime ,
                                      "dd.MM.yyyy HH:mm:ss", null);

10-06 04:07