I started programming just about 2 weeks ago and my friend said I could ask you guys for help if I need any.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int x;
string s;
do
{
Console.WriteLine("input a number in the range of 0 -100");
s = Console.ReadLine();
x = s.ToInt32();
}
while (x < 0 || x > 100);
Console.WriteLine("ok you have chosen");
Console.ReadKey();
}
}
}
My first time running into that x=s.ToInt32
(I've read that int
is supposed to contain a number and not a string
or letters..) and the error:
'string' does not contain a definition for 'ToInt32' and no extension method 'ToInt32'
accepting a first argument of type 'string' could be found (are you missing a using
directive or an assembly reference?)
C:\Users\user\Documents\Visual Studio11\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs 19 23 ConsoleApplication1