dcsimg
 

Submitted by: Srinath M S(srinath_ms@yahoo.com)

Friday Aug 9th 2019 by Srinath M S

Language: .NET, Expertise: Beginner - Learn more about how to use a function in C# to discover how many more days are left in a given countdown.

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};
}
Home
Mobile Site | Full Site