问题描述
每次当我输入 z 作为输入时,它都会失败。我不明白问题是什么。它得到错误“System.FormatException:输入字符串的格式不正确” Dsales 是一个进入转换器以转换为美元和美分的整数。这有什么不对的?
using System;
using static System.Console;
using System.Globalization;
class HomeSales
{
static void Main()
{
string response;
int dsales = 0;
int esales = 0;
int fsales = 0;
int initial;
string damount;
string eamount;
string famount;
int damounti;
int eamounti;
int famounti;
WriteLine ("Enter a salesperson initial");
response = ReadLine();
//initial = Convert.ToInt32(response);
while (response == "d" || response == "D")
{
WriteLine ("Enter Line of sale");
damount = ReadLine();
damounti = Convert.ToInt32(damount);
dsales = dsales + damounti;
}
while (response == "z" || response == "Z")
{
WriteLine("Danielle sold {0}",dsales.ToString("C",CultureInfo.GetCultureInfo("en-US")));
}
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)