110,538
社区成员
发帖
与我相关
我的任务
分享
public static void Main(string[] args)
{
int i;
string u;
bool x = true;
while(x)
{
Console.WriteLine("请输入等级");
Console.WriteLine("输入Q退出");
i=Convert.ToInt32(Console.ReadLine()); ————》这个地方;
u=Console.ReadLine();
if(u.ToUpper()=="q") ——————》 这个地方;
{
x=false;
}
M n = new M();
n.Money(i);
}
public static void Main(string[] args)
{
int i;
string u;
bool x = true;
while(x)
{
Console.WriteLine("请输入等级");
Console.WriteLine("输入Q退出");
i=Convert.ToInt32(Console.ReadLine());
u=Console.ReadLine();
u.ToUpper();
if(u=="Q")
{
x=false;
}
M n = new M();
n.Money(i);
}
调试器抛出异常System.FormatException:
Input string was not in a correct format.
StringToNumber()
ParseInt32()
ToInt32()
Main() - d:\My Documents\SharpDevelop Projects\xy\Program.cs:31,4
static void Main(string[] args)
{
int i;
string u;
bool x = true;
while (x)
{
Console.WriteLine("请输入等级");
Console.WriteLine("输入Q退出");
u = Console.ReadLine();
u.ToUpper();
if (u == "Q")
{
x = false;
}
else
{
try
{
i = Convert.ToInt32(Console.ReadLine());
M n = new M();
n.Money(i);
}
catch (Exception ex1 )
{
Console.Write(ex1.ToString());
return;
}
}
}