Error 1 Cannot apply indexing with [] to an expression of type 'int'

后端 未结 2 458
花落未央
花落未央 2021-01-06 14:27

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 <

相关标签:
2条回答
  • 2021-01-06 15:27

    You need to declare ipoints as an array of ints, not just an int.

    Change int ipoints to int[] ipoints.

    0 讨论(0)
  • 2021-01-06 15:27

    You're trying to use an int like an int[] array.

    Here:

    static void GetPoints(int ipoints, string srestaurant)
    //                    ^^^^^^ not an array
    

    You're doing it here:

    ipoints[index] = iinput;
    //     ^^^^^^^ its not an array
    

    Either make it an array, or rethink what you're trying to do.

    0 讨论(0)
提交回复
热议问题