我正在尝试制作一个命令行程序,它会询问您是否希望它发出哔哔声。我继续阅读System.FormatException
下面的代码。之后我就得到了问题Console.WriteLine("how many times should i beep?");
。我通过console.read();//pause
在此行之后放置一个正确的方法找到了解决方法。
我的问题是我做错了什么?还是我想在那条线之后暂停?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("how fast would you like the sounds to play?");
Console.WriteLine("70 = fast and 300 = slow can pick any number inbetween");
string choice = Console.ReadLine();
int speed = Convert.ToInt32(choice);
Console.Write(speed);
Console.Read();//pause
Console.WriteLine("how many times should i beep?");
string choice2 = Console.ReadLine();
int j = Convert.ToInt32(choice2);
Console.Write(j);
Console.Read();//pause
for (int i = 0 ; i < j; i++)
{
Console.Beep(1000, speed);
}
}
}