我的程序不仅要能够比较 us style 与 us style format ,还要比较 us style (mm/dd/yyyy)
vs non us style (dd/mm/yyyy)
。怎么做?到目前为止,这就是我所拥有的,它只适用于比较相同的风格:
DateTime my_dt = new DateTime(); // this can be mm/dd or dd/mm
// depending on where it run
DateTime new_dt = Convert.ToDateTime(us_dt);
int compare = DateTime.Compare(new_dt, my_dt);
当 my_dt 为 dd/mm 时,出现错误:
System.FormatException: String was not recognized as a valid DateTime.
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
at update.Program.Process(String ftp_path, String action)