Je reçois cette FormatException après ma mise à niveau vers VS 2010. Rien de vraiment spécial. code:Strange FormatException après la mise à niveau dans VS 2010
private void ManageDateEditControls()
{
apoDateEdit.DateTime = DateTime.Parse(string.Format("01/{0}/{1}", DateTime.Now.Month-1, DateTime.Now.Year));
eosDateEdit.DateTime = DateTime.Parse(string.Format("{0}/{1}/{2}", GetLastDayOfMonth(DateTime.Now.Month + 1),
DateTime.Now.Month - 1, DateTime.Now.Year)); <-- FormatException occurs in this line.
}
private static int GetLastDayOfMonth(int month)
{
// set return value to the last day of the month
// for any date passed in to the method
// create a datetime variable set to the passed in date
DateTime dtTo = new DateTime(DateTime.Now.Year, month, 1);
// overshoot the date by a month
dtTo = dtTo.AddMonths(1);
// remove all of the days in the next month
// to get bumped down to the last day of the
// previous month
dtTo = dtTo.AddDays(-(dtTo.Day));
// return the last day of the month
return dtTo.Day;
}
Disons que vous obtenez maintenant si vous exécutez ce 31/6/2010. Je pense que c'est une date valide. J'ai testé la date qui est générée et c'est ok ... ce projet n'a jamais eu ce problème alors qu'il travaillait dans VS 2008.
Des idées?
Je suis un peu confus - pourquoi le 31/6/2010 serait-il une date valide? –