unity3d c# 的代码错误
Dictionary<int,string[]>openWith0=newDictionary<int,string[]>();//定义字典Dictionary<int,...
Dictionary <int, string[]> openWith0 = new Dictionary<int, string[]>();//定义字典
Dictionary <int, string[]> openWith1 = new Dictionary<int, string[]>();//定义字典
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<int,string[]>.this[int]' has some invalid arguments
Assets/script/gamelogic.cs(55,44): error CS1503: Argument `#1' cannot convert `string' expression to type `int' 展开
Dictionary <int, string[]> openWith1 = new Dictionary<int, string[]>();//定义字典
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<int,string[]>.this[int]' has some invalid arguments
Assets/script/gamelogic.cs(55,44): error CS1503: Argument `#1' cannot convert `string' expression to type `int' 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询