Cannot implicitly convert type 'string' to 'int'

  • Thread starter Thread starter Chris LTQ
  • Start date Start date
C

Chris LTQ

Guest
Trying to learn C# and as such i have deicded to re-create and old game i used to play called "Hampsters"

My problem is this:

"testing.cs(15,23): error CS0029: Cannot implicitly convert type 'string' to 'int'"


Code Below. Can someone please explain the answer, without giving me the answer if possible? IE Just tell me what i am doing wrong, dont give me the correct code.

Kindest regards,

C.

using System;

namespace testing
{

class Program
{

static void Main(string[] args)
{

int hampstersBought;

Console.WriteLine("How many hampsters would you like? : ");
hampstersBought = Console.ReadLine();
Console.Write(hampstersBought);

}
}
}

Continue reading...
 
Back
Top