作业帮 > 综合 > 作业

unity3d c# 的代码错误

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/11 01:30:50
unity3d c# 的代码错误
Dictionary openWith0 = new Dictionary();//定义字典
Dictionary openWith1 = new Dictionary();//定义字典
openWith0.Add(0, "0,500,1000,1500,2000,3500,4500,6500,7500,8500,10000,14000,15000,16000,18000,19000,21000".Split(','));
openWith1.Add(0, "1,2,3".Split(','));
for (int i = 0;i < openWith0[0].Length;i++)
{
for (int j = 0;j < openWith1[openWith0[0][i]].Length;j++)//就是这行报错
{
if (j == 0)
{
Instantiate(m1,new Vector3 (Random.Range(200,300), Random.Range(-800,-700),0),transform.rotation);
}
}
}
报错:
Assets/script/gamelogic.cs(55,44): error CS1502: The best overloaded method match for `System.Collections.Generic.Dictionary.this[int]' has some invalid arguments
Assets/script/gamelogic.cs(55,44): error CS1503: Argument `#1' cannot convert `string' expression to type `int'
unity3d c# 的代码错误
openWith1 的key是int型的,
openWith0[0][i] 得到的是字符串