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 trial

C# C# Basics (Retired) Console I/O Formatting Output

Knud Back
Knud Back
1,248 Points

Why do I get an error when I write "using System;" as the first part of my code?

The Quiz as me to use "Console.ReadLine();" and not "System.Console.ReadLine();". In that case I would expect that defining the namespace "System" would be requeried. But the quiz will not accept my answer when start the code by writing "using System;".

1 Answer

Simon Coates
Simon Coates
28,694 Points

It may be inserting your code into a main method behind the scenes. That main method may reside in a class that already includes the line that provides you access to System.Console. A lot of the quizzes ask you for loose code, rather than making you write the complete code structure (eg. class, namespace etc), and it can make things confusing.