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 Methods Method Return Values

Christopher Borchardt
Christopher Borchardt
2,908 Points

Console does not contain a definition for "ReadLine"

using System; using System.Threading;

class Program {

static void Ask(string question)
{
    Console.WriteLine(question);
    string answer = Console.Readline();
    Console.WriteLine(answer);

}

static void Main(string[] args)
{
    Console.WriteLine("Welcome to the cat food store!");
    Ask("How many cans are you ordering?");      
}

}

when I go to complie i get an error

Program.cs(10,31): error CS0117: 'Console' does not contain a definition for 'Readline' [/home/treehouse/workspace/workspace.csproj]

3 Answers

Steven Parker
Steven Parker
231,198 Points

C# is case-sensitive, and this code refers to "Readline" (with a lower-case "l") instead of "ReadLine" (capital "L").

Christopher Borchardt
Christopher Borchardt
2,908 Points

i have tried with both a lowercase and an capital L in the line, the video has it with a capital L. but in both cases i'm getting the same error.

Christopher Borchardt
Christopher Borchardt
2,908 Points

nvm, i set it back to capital again and now it works