Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial3 Answers
Sara Rena Anderson
15,045 PointsFor the first date:
string.Format("The current date and time is {0}.", DateTime.Now)
For the second
string.Format("The current date and time is {0:f}.", DateTime.Now)
Remember for the third question, "I like apples" that the first item is "0" not "1":
string.Format("I like {0} and {1}, but I don't like {2}.", "apples", "oranges", "bananas")
Steven Parker
231,198 PointsWithout knowing which question is troubling you, here's some basic hints:
- the questions all involve putting placeholders in the string for formatting.
- basic placeholders have the format "{n}" where the n is the placeholder number (starting with 0)
- special placeholders have the format "{n:f}" where f is a format specifier
Steven Parker
231,198 PointsWhile custom formats would work in actual practice, I think the challenge is expecting you to use the standard single-letter format specifiers.
You can find them used in the videos, or in the official MSDN Documentation.
Leo Ngai
2,184 PointsThanks Steven! There are two actually: To fill the blank, the resolution can be a lot but the system does not allow me to pass them (I guess the system is byte-by-byte comparism to its unique answer).
- Complete the following code in order to produce a string that prints the current date.
string.Format("The current date is _____________________", DateTime.Now.Date)
i.e. if I fill {0:MM/dd/yy}, it reports error.
- Complete the following code in order to produce a string that prints the current date and time, but formatted as a full date/time pattern (short time) like so: "The current date and time is Monday, June 15, 2009 1:45 PM"
string.Format("The current date and time is _____________________", DateTime.Now)
i.e. if I fill {0:dddd, mm yyyy H:mm:ss}, it reports error as well.....
Steven Parker
231,198 PointsSteven Parker
231,198 PointsWhich question?
This quiz has 3 questions.