如何查找输入的数量?
static void Main(string[] args)
{
string x;
double t, s = 1;
while ((x = Console.ReadLine()) != null)
{
}
答案 0 :(得分:0)
要将输入的数字设为double,您可以使用double.TryParse Google here转换" x"进入" t"然后以某种方式对其采取行动。如果您想要更具体的内容,您需要分享您尝试做的事情(预期输入/预期输出)。你的英语"输入的数字是多少"目前尚不清楚。
static void Main(string[] args)
{
string x;
double t,tot=0, s = 1;
while ((x = Console.ReadLine()) != null)
{
if(double.TryParse(x,out t))
{
//t is now the number entered as a double -- process
tot+= t;
Console.WriteLine(s==1?"Please enter your second number":"The sum of your "+s.ToString()+" numbers is "+tot.ToString("N0"));
s++;
}else{
Console.WriteLine("You may only enter numbers. Please try again.\n");
}
}