James Brodski
James Brodski

Reputation: 11

Why is my for loop telling me I am converting int to bool?

Here is my code...

for (int Position = 0; CardsInDeck.Length; Position++) 
{
    if (RandomlySelectedCard == CardsInDeck [Position]) 
    {
        Position = 0;
    } else {
        CardsInDeck [Position] = RandomlySelectedCard;
    }
}

Unity is telling me that it cannot convert int to bool, but I have checked everything and it looks good. I am making a card game by the way.

Upvotes: 1

Views: 74

Answers (1)

Akintayo Jabar
Akintayo Jabar

Reputation: 846

Your for loop says:

for (int Position = 0; CardsInDeck.Length; Position++) 

the second argument in the for loop is supposed to be a condition hence it should be:

for (int Position = 0; Position < CardsInDeck.Length; Position++)

Upvotes: 6

Related Questions