我大约 2 周前开始编程,我的朋友说如果我需要任何帮助,我可以向你们寻求帮助。
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();
}
}
}
我第一次遇到这种情况x=s.ToInt32
(我读过它int
应该包含一个数字而不是一个string
或字母..)和错误:
'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