Reputation: 41
I am trying to create a method that will step through an array with a for loop and if they array subscript is greater than or equal to the minimum requirement a string array subscript will be added to a listbox.
Here is my feeble attempt, along with the method I've tried below it. When calling the method AwardMinimum, the whole thing is incorrect stating, "has some invalid arguments". Commented out is what every level looks like. (level <=10, level >10 && <=20, etc..)
if (level <= 10)
{
AwardMinimum(perDayArray, min, awardsArray);
/*for (int i = 0; i < STATSIZE; i++)
{
if (perDayArray[i] >= 2)
{
awardListBox.Items.Add(awardsArray[i]);
}
}*/
}
The method itself
private void AwardMinimum(double perDay, int min, string awards)
{
for (int i = 0; i < STATSIZE; i++)
{
if (perDay >= min)
{
awardListBox.Items.Add(awards);
}
}
}
Upvotes: 0
Views: 334
Reputation: 431
perDayArray
and awardsArray
are array but in the AwardMinimum(double perDay, int min, string awards)
method you use them as double and string.
it should be :
private void AwardMinimum(double[] perDay, int min, string[] awards)
or
AwardMinimum(perDayArray[i], min, awardsArray[i]); //where i is the index
Upvotes: 1