我有这些字符串数组:
string[] BayReplyArray1 = new string[30];
string[] BayReplyArray2 = new string[30];
string[] BayReplyArray3 = new string[30];
... up to 10
Run Code Online (Sandbox Code Playgroud)
我想在这样的循环中访问它们:
for (int i = 1; i < 11; i++)
{
BayReplyArray[i] = "test";
}
Run Code Online (Sandbox Code Playgroud)
它说BayReplyArray在当前上下文中不存在.我可以看出为什么它很困惑,但我怎么能做到这一点?
对此的简单解决方案是多维阵列.
string[,] BayReplyArrays = new string[10,30]
for(int i = 0; i < 10; i++)
{
for(int j = 0; j < 30; j++)
{
BayReplyArrays[i,j] = "test";
}
}
Run Code Online (Sandbox Code Playgroud)
这是MSDN多维数组指南:https://msdn.microsoft.com/en-us/library/2yd9wwz4.aspx
| 归档时间: |
|
| 查看次数: |
82 次 |
| 最近记录: |