1 回答
TA贡献1785条经验 获得超4个赞
用 while 循环替换 if 条件,试试这个:
static void Main(string[] args)
{
double value1;
int round1;
while (true)
{
Console.Write("Enter a decimal-number: ");
string StrValue = Console.ReadLine();
bool success = Double.TryParse(StrValue, out value1);
while (!success)
{
Console.WriteLine("You need to use (,) as decimal-sign according to Swedish standard!"); //From here I want a loop if . is used instead of ,
StrValue = Console.ReadLine();
success = Double.TryParse(StrValue, out value1);
}
Console.Write("With how many decimal-numbers do you want to round it down to?: ");
string StrRound = Console.ReadLine();
bool success1 = Int32.TryParse(StrRound, out round1);
if (!success1)
{
Console.WriteLine("Only use whole numbers when rounding");
}
else break;
}
}
}
- 1 回答
- 0 关注
- 89 浏览
添加回答
举报