本文介绍了错误1无法应用与[]的索引类型为'诠释'的前pression的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Microsoft Visual Studio 2010和C#。这是一家在我的控制台程序调用其他形式的功能,但我似乎无法得到输入到阵列 ipoints
。
静态无效GetPoints(INT ipoints,串srestaurant)
{
INT索引= 0;
INT iinput;
对于(指数= 0;指数小于5;指数++)
{
Console.Write(请输入多少分+ srestaurant [指数] +了:);
iinput = Convert.ToInt32(到Console.ReadLine()); 而(iinput&℃,放大器;&放大器; iinput→20)
{
Console.Write(请输入多少分+ srestaurant [指数] +了:);
iinput = Convert.ToInt32(到Console.ReadLine());
}
ipoints [指数] = iinput;
}
}
解决方案
您需要声明ipoints为int数组,而不仅仅是一个int。
修改 INT ipoints
到 INT [] ipoints
。
I am using Microsoft Visual Studio 2010 and C#. This is a function that is being called form elsewhere in my console program, but I can't seem to get input into the array ipoints
.
static void GetPoints(int ipoints, string srestaurant)
{
int index = 0;
int iinput;
for (index = 0; index < 5; index++)
{
Console.Write("please enter how many points " + srestaurant[index] + " got : ");
iinput = Convert.ToInt32(Console.ReadLine());
while (iinput < 0 && iinput > 20)
{
Console.Write("please enter how many points " + srestaurant[index] + " got : ");
iinput = Convert.ToInt32(Console.ReadLine());
}
ipoints[index] = iinput;
}
}
解决方案
You need to declare ipoints as an array of ints, not just an int.
Change int ipoints
to int[] ipoints
.
这篇关于错误1无法应用与[]的索引类型为'诠释'的前pression的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!