【发布时间】:2014-02-03 09:59:18
【问题描述】:
我有一个 for 循环,它创建一个具有设定数量索引的字符串数组并用字符串填充它。我将有第二个 for 循环来创建更多数组并将这些数组命名为我之前数组中的字符串。它不会将字符串作为名称,所以我卡住了。有什么建议可以解决这个问题?
我在 C# 中这样做。
谢谢
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class World : MonoBehaviour {
public int WorldSize;
const int q = 1000;
const int w = 100;
string [] world;
// Use this for initialization
void Awake () {
world = new string[((WorldSize / q) * 2)];
//int[,,] map = new string[((WorldSize / q) * 2)];
for (int i = 0; i < ((WorldSize / q) * 2); i++){
string h = i.ToString();
world[i] = ("Region" + h);
Debug.Log(world[i]);
}
Dictionary<string, string[]> regions = new Dictionary<string, string[]>();
for (int i = 0; i<world.Length; i++) {
string h = i.ToString();
regions.Add(world[i], new string[q/w]);
Debug.Log(regions["Region" + h]);
}
}
}
【问题讨论】:
-
请提供您目前拥有的代码,并让我们知道它在哪里失败/无法编译。