Arrays and Classes | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

Arrays and Classes

I created a class that is supposed to define a public array variable, and use a constructor to create an object in the main method by being passed as an argument. Also inside this class is a method that iterates through the int values inside the array and should only display them if they are even values. But it wonā€™t compile, itā€™s not a method that uses a return statement so I made it void with an Iā€™d loop to check the conditional. Iā€™ve been stuck on this for a day and a half and canā€™t think of how I would go about changing this method to fix it. Class ArrTest and itā€™s method IsEven() are in question. https://code.sololearn.com/cTs0746Sa73K/?ref=app

7th Jan 2020, 7:34 PM
Josh S
Josh S - avatar
2 Respostas
+ 3
Replace line 67 with just this: a1.IsEven(); Because your IsEven() function returns nothing, there is no value for Console.WriteLine to print.
7th Jan 2020, 7:49 PM
Tibor Santa
Tibor Santa - avatar
+ 3
Oh wow, right over my head. Thank you both so much for pointing me in the correct direction : )
7th Jan 2020, 7:59 PM
Josh S
Josh S - avatar