From the course: C# and .NET Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Solution: How many days?

Solution: How many days? - C# Tutorial

From the course: C# and .NET Essential Training

Solution: How many days?

(upbeat music) - All right. Let's take a look at my solution to the challenge. And remember, it's not important that your solution exactly matches mine. There's almost always multiple ways to solve any given programming scenario. So my code starts off with a couple of local variables. There's one to hold the string that the user enters and one to represent today's date. So note that I'm using the today property because I don't want my code to take any hours or minutes into consideration, just the date. So the bulk of the work is contained within this do while loop. The program prints the greeting and then asks for the date, and the user enters the date. And if they type in the word exit, then the loop breaks and the program exits. The parsed date variable is used to hold the result of the TryParse function to convert the user's input into a date. And if the conversion is successful, then I compare the enter date…

Contents