which of the following approaches has better performance:
first way:
public static DateTime GetAnoNovo()
{
if(DateTime.Now.ToString("MMdd") == "0101") return new DateTime(DateTime.Now.Year, 01, 01);
else return new DateTime(DateTime.Now.Year + 1, 01, 01);
}
second way:
public static DateTime GetAnoNovo()
{
if(DateTime.Now.ToString("MMdd") == "0101")
{
return new DateTime(DateTime.Now.Year, 01, 01);
}
else
{
return new DateTime(DateTime.Now.Year + 1, 01, 01);
}
}
Aucun commentaire:
Enregistrer un commentaire