Help with this coding problem.
Hello all, can someone diagnois what does it mean by this code stack?
The problem is
I've tried converting the array in the method to an int type but that doesn't work
7 Replies
The
int[]
in your method definition is you saying that the method will return an array of ints, but you're not doing thatOh, thank you
it's still not converting even with the above code
Convert.ToInt32(nums)
Is this line not giving you an error?
Also not really sure what you're trying to do in your return statement, or why you're assigning to a new variable to instantly return itThe Convert.ToInt32 isn't giving me any errors, but I am attempting to have it where the numbers when divided by 2 come out as even, else they come out as odd. It requires that i have a return as an array though
I don't think you mean to be passing the whole array into the convert method though, or why you'd need to convert to int when it's already an array of ints?
I am attempting to have it where the numbers when divided by 2 come out as even, else they come out as oddI'm not sure what you mean here?
You will need to use a loop, then
Loop over the items in
nums
Parse each to an int
Then check if that int is even or oddThanks
I thought I would have to cast the array as an integer first, then back return as an array