I have a hefty list of if statements which compare the current date to a set due date, it then displays how many days remain until the deadline or show if it has already been met. Just wondering if there is a more efficient way to go about this.
Below is an example of one of the 'sets' of statements, there are around 7 more of these. It's almost kind of gross, looking for a little help or a point in the right direction in how I can tidy it up. Thanks!
if (DateTime.Now >= programming1)
{
lblReadDate.Text = "Due date for Programming Assignment 1 has been reached (" + programming1.ToShortDateString() + ").";
}
else
{
lblReadDate.Text = "Days remaining until Programming Assignment 1 deadline: " + daysRemaining1.ToString("0");
}
if (DateTime.Now >= programming2)
{
lblReadDate2.Text = "Due date for Programming Assignment 2 has been reached (" + programming2.ToShortDateString() + ").";
}
else
{
lblReadDate2.Text = "Days remaining until Programming Assignment 2 deadline: " + daysRemaining2.ToString("0");
}
Aucun commentaire:
Enregistrer un commentaire