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
176,598 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