Tom*_*Tom 2 c# arrays loops for-loop
好吧,我正在尝试创建一个基本上使用for循环来显示一周中的日期的程序,我的代码看起来很好,运行正常,但是当我碰巧运行它...它出现了"它的日子一周是System.String []"..而我希望它显示星期几是星期一...星期几是星期二......星期三......等等.
这是我到目前为止为此编写的代码:
//Declare variables
int iDays;
//Declare array
const int iWEEK = 7;
string[] sDays = new string[iWEEK] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
//Display the days of the week
for (iDays = 0; iDays < iWEEK; iDays++)
{
Console.WriteLine("The day of the week is " + sDays);
}
//Prevent program from closing
Console.WriteLine();
Console.WriteLine("Press any key to close");
Console.ReadKey();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1868 次 |
| 最近记录: |