FAQ: Data Types and Variables - Converting Data Types

Agreed, ran into this as well. It just jumped from a great first lesson learning how to stay afloat into throwing you into the depths in the other lesson.

{
static void Main(string args)
{
// Ask user for fave number
Console.Write("Enter your favorite number!: ");
int faveNumber = Console.Readline()

  // Turn that answer into an int

Why does this code not get me past part 1 in the exercise? and how are people uploading pictures to this forum?

For Step 1, after clicking the Run button, are you typing dotnet run into the console? Pressing the Run button will save your work. Once you type in dotnet run into the console, you should get the green tick-mark for Step 1.

There is an “Upload” button in the forum post editor.

scrn1

There does not seem to be a way past the first step. No matter what I put in, right or wrong, I never get the first step correct.

If anyone has any advice, please help. My son wants to pay a subscription to this site and I’m not going to do so if this is what he’s going to be presented with.

EDIT: I’m adding the line int faveNumber = Console.ReadLine();
and then using dotnet run

Are you pressing the Run button after adding the line? If you omit this, then your file will not be updated even though the on screen editor may show your edits.
For Step 1, you should:

  • Below the Console.Write() statement, you should add your int faveNumber = Console.ReadLine(); statement.

  • Then, you should click the Run button. It won’t actually run your code, but it will save the change you made above.

  • Finally, type dotnet run in the console.

If the above still doesn’t work, then click on the “Copy to Clipboard” button (which is next to the Run button). After copying, you can paste your code in the forums using the </> button (see [How to] Format code in posts for more details). Also, mention the exact feedback/error message that is shown at the bottom.

your instructions did not work. I still have the red X for step one.

Here’s the code, although it’s visible in the image:

using System;

namespace FavoriteNumber
{
  class Program
  {
    static void Main(string[] args)
    {
      // Ask user for fave number
      Console.Write("Enter your favorite number!: ");
      int faveNumber = Console.ReadLine();
      // Turn that answer into an int



    }
  }
}

Try moving the statement below the comment i.e. try doing:

// Ask user for fave number
Console.Write("Enter your favorite number!: ");

// Turn that answer into an int
int faveNumber = Console.ReadLine(); 

Make sure you click the Run button after moving the statement. Then type    dotnet run    in the console. If it works, the console will still show error (as expected and explained in Step 2). but Step 1 will hopefully show the green check mark.

No, that changed nothing.

I’m not really in the mood to debug the beginning tutorials of a major website. Especially one that purports to teach my son how to code. I’ll just go elsewhere, thanks.

EDIT: On top of that, the error message that’s posted in the tutorial suggests the error is in line 10… the Console.Write() line that was GIVEN TO US.

1 Like

2024 still in production

For people struggling to get past the 3rd example, just input the following: