117k views
4 votes
What is wrong with my code?

using System;

namespace FavoriteNumber
{
class Program
{
static void Main(string[] args)
{

Console.Write("Enter your favorite number!: ");
int faveNumber = Console.ReadLine()
int number = Convert.ToInt32("string value")
will give 30 points to who ever is right

User Namuol
by
6.0k points

1 Answer

2 votes

Answer:

namespace FavoriteNumber

{

class Program

{

static void Main(string[] args)

{

Console.Write("Enter your favorite number!: ");

string faveNumber = Console.ReadLine();

int number = Convert.ToInt32(faveNumber);

Console.Write($"Your favorite number seems to be {number}");

}

}

}

Step-by-step explanation:

You were close. Spot the differences. A statement should end with a semicolon. Console.ReadLine() returns a string. That string is the input of what you want to convert to an int.

And of course you need to match each opening brace { with a closing brace }.

User Alexandre Legent
by
5.5k points