+ 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
2 Respuestas
+ 3
Replace line 67 with just this:
a1.IsEven();
Because your IsEven() function returns nothing, there is no value for Console.WriteLine to print.
+ 3
Oh wow, right over my head. Thank you both so much for pointing me in the correct direction : )