dimanche 20 juin 2021

Checking every array member in an if statement to look for a specific array member

I'm trying to create a system where I have a string array where each member says the same thing ("Empty") but an if statement/foreach combo changes just one of those "Empty"s to a "Full" when a button is clicked. So first I start the if statement with something like

if (inv[0] == "Empty" || inv[1] == "Empty" || inv[2] == "Empty")

etc till it covers each member of the array making sure that there is at least one "Empty" (for it's supposed to only change an "Empty" to "Full" if there actually is an "Empty").

After that, I think I'm supposed to use a foreach, but I'm not sure how.

Anyway, any help would be appreciated. If you need me to send me my code, let me know.

Aucun commentaire:

Enregistrer un commentaire