int.Parse()和之间的主要区别是Convert.ToInt32()什么?大约两周前我开始编程,我的朋友说如果我需要的话,我可以请求你们帮忙.
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();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我第一次x=s.ToInt32遇到这个(我读过它int应该包含一个数字,而不是一个string或字母..)和错误:
'string' does not contain a definition for 'ToInt32' and no extension method 'ToInt32' …Run Code Online (Sandbox Code Playgroud) c# ×2