c# - Error: Cannot apply indexing with [] to an expression of type 'method group' -


     private int[] runwayfee;    public string getmonthwithhighrevenue()         {             return returnmonth(runwayfee.tostring[getindexofhighrevenue()]);         } public int getindexofhighrevenue()     {         int max = 0;          (int = 0; > runwayfee.length; i++)             if (runwayfee[i] > runwayfee[max])                 max = i;          return max;     } 

tried million different options keep getting errors line:

return returnmonth(runwayfee.tostring[getindexofhighrevenue()]);

you've got tostring() , [] operators in wrong place.

returnmonth(runwayfee[getindexofhighrevenue()].tostring()); 

you jamming lot of code 1 line, , made easy confused.

in these situations, strategy use break down multiple lines of code:

    public string getmonthwithhighrevenue()     {         int index = getindexofhighrevenue();         int highfee = runawayfee[index];         string highfeestring = highfee.tostring();         string month = returnmonth(highfeestring);         return month;     }  

i don't know if work, because don't know parameter returnmonth expects. if break down multiple lines, error become more obvious you.


Comments