本文介绍了用户在控制台应用程序中的数组中输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取用户输入的数组?当我使用ReadLine
代码时,出现错误:
How can I get an user input into an array? When I use the ReadLine
code it gives an error:
string[] str;
str = new string[10];
Console.WriteLine("enter the string");
str[0] = Console.ReadLine();
我应该像上面一样使用0吗?
[正确的代码格式]
Should I use 0 as I have used above?
[Corrected code formatting]
推荐答案
string []answer = new string[10];
for(int i = 0;i<answer.length;i++)
{
answer[i]= Console.ReadLine();
}
这篇关于用户在控制台应用程序中的数组中输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!