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 trialGlen Chia
914 PointsOutput methods
What is the difference between/when to use the following: 1) Console.WriteLine("You have entered" + entry + "minutes"); 2) Console.WriteLine("You have entered {0} minutes", entry);
1 Answer
Steven Parker
231,236 PointsIt's your choice if you prefer to concatenate the string yourself, or allow the formatting mechanism to insert the value for you. I'd personally use the second version primarily because it's a bit more compact.
But perhaps even better is to use a string interpolation:
Console.WriteLine($"You have entered {entry} minutes");