See how to use this function in C# to discover how many more days are left in a given countdown.
DateTime startDate = DateTime.Now;
DateTime endDate = DateTime.Now.AddDays(-1);
TimeSpan t = startDate - endDate;
double days = t.TotalDays;
string result = "This is the result";
if (days < 0)
{
result = "phew, the date is in the past";
}
else if (date = 0)
{
result = "We are right on the dot";
}
else
{
result = string.format("{0} days to go!", days};
}
Visit the DevX Tip Bank