dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Tip: Countdown Timer Function in C#

Learn more about how to use a function in C# to discover how many more days are left in a given countdown.


advertisement

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


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

 





   
Srinath M. S. says: "I would love to leave a footprint in this flat world."
Thanks for your registration, follow us on our social networks to keep up-to-date