-1
だから私がしようとしているのは、ユーザー入力のリストをとり、配列に直接配置することです。私は何百もある可能性があるので、各入力に変数を割り当てることなくこれをしたいと思います。関数の値を変数に代入して戻すことで値を返す
static void writeAndWait(String statement, int millisecondsToWait)
{
Console.WriteLine(statement);
Thread.Sleep(millisecondsToWait);
return;
}
static void Main(string[] args)
{
//I am using ArrayLists because they will store as many values as needed wether it be 1 or 1,000,000 or more
ArrayList Name; //Declaring Name
ArrayList Time; //Declaring Time
ArrayList Path; //Declaring Path
Name = new ArrayList(); //Name will be used to store the names of the timers the user inputs
Time = new ArrayList(); //Time will be used to store the times of the timers the user inputs
Path = new ArrayList(); //Path will be used to store the path line of the timers the user inuts;
writeAndWait("Hello, if you want to add timers all you need to do is type a name and press enter, say how long you want the timer to run for in minutes, and then add a number 1-10 any timers with the same number at the end will run sycrnasly, and any timers with diferant nubers will run async", 2000);
Name.Add(Console.ReadKey().ToString());
Console.WriteLine(Name[0]);
}
Console.WriteLineをしたばかり返す「Console.ReadKey()。ToStringメソッド())
私はそれがユーザーの入力したキーを返すようにしたいと思います。または、Console.ReadKeyの戻り値
FYI、あなたはおそらく(.aspxのhttps://msdn.microsoft.com/en-us/library/system.console.readline(V = vs.110))[Console.ReadLine]を使用したいです'Console.ReadKey'の代わりに –
' ArrayList'の代わりに 'List'を使ってみませんか?また、なぜあなたのメッセージは名前を入力してEnterを押すと言うので、 'Console.ReadLine'ではなく' Console.ReadKey'を使用していますか? –
juharr
私はテストとしてReadKeyを使っていました。私はリストから値を読み取る際にいくつかの問題を抱えていたので、なぜArrayListsに切り替えました。リストを使用する方法を示す際にいくつかのコードにコメントすることができれば、それは素晴らしいものになります。しかし、まだacctuallコマンドではなく値を返すだけでよいのでしょうか? –