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 trialVivian Coday
11,881 PointsFurther Simplification
Can we simplify the Main method further by removing the variable declaration and instead put the call to the Ask method within the call to Console.WriteLine?
static void Main(string[] args) {
Console.WriteLine("Welcome to the cat food store!");
Console.WriteLine(Ask("How many cans are you ordering? "));
}
1 Answer
Steven Parker
231,268 PointsYou certainly could do that if writing the input back to the output was the only thing the program was going to do.
But it's necessary to store the value in a variable to be able to use it later for other things like computing the order price. You'll see this being done in later examples as the course progresses.