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 trialJude Brown
Courses Plus Student 629 PointsWhat is wrong with my code vs the actual solution?
Hi,
I wrote my code and then saw what the instructor did. My code works, but it is different. My assumption is that the instructors way of doing things is more efficient or better formatted or something. Can you explain the differences? I didn't bother with a snapshot because it is such a small amount.
Console.Write("What is your name? ");
var name = Console.ReadLine();
Console.Write("What is your favourite book? ");
var book = Console.ReadLine();
Console.WriteLine("My name is " + name + " and my favourite book is " + book + ".");
1 Answer
Steven Parker
231,248 PointsUntil you post a link to the original code for comparison, I just wanted to point out that "different" doesn't necessarily mean "wrong". In fact, there can be many programming choices to be made in implementing a solution, and if they produce the same result, it's possible that all of them are correct.
Unless I misunderstand the intention, the code shown here seems to be just fine as-is.
Ted Dunn
43,783 PointsTed Dunn
43,783 PointsHey Jude (bet you've never heard that before)
You have not provided the course/video you were working on so it is not possible for anyone to determine the differences in your code vs. that of the instructor.