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 trialYamaan Kashif
102 PointsI don't understand why Console.WriteLine(question) is necessary when the method already has a name, "ask"
I don't understand why Console.WriteLine(question) is necessary when the method already has a name "ask". We do we have to then use the name question in "Console.WriteLine"?
I just don't understand the purpose of string question when the method can already be called with Ask();
2 Answers
Steven Parker
231,272 PointsThe Ask
method outputs a question and then waits for an answer. So, Console.WriteLine
is still used when you want to output only.
Also, Console.WriteLine(question)
is the way it is used inside the definition of Ask
, where calling itself would cause a recursive overflow (an infinite loop).
Meme H
302 PointsThe Console.WriteLine()
is a method created by C# SDK itself;
Or you can see Console.WriteLine()
as the method existing in the system which you don't need to write but use/call directly.
While the Ask()
is a method that we wrote for this lesson.