- Home /
Question by
shadowsaint669 · May 14, 2012 at 12:20 AM ·
c#loopfor
C# for loop with 2 ints
for (int i = 0 , int k = 0; i < 5; i ++ , k++){
spellRingTextString[i] = gameData.spellList[k].spellName;
}
Mono is telling me there is something wrong with my for loop.
Comment
Answer by whydoidoit · May 14, 2012 at 12:21 AM
Drop the second "int":
for (int i = 0 , k = 0; i < 5; i ++ , k++){
spellRingTextString[i] = gameData.spellList[k].spellName;
}
I love when it is poor syntax on my end. Almost always is, or a spelling error.
Thanks a ton.
Answer by karl_ · May 14, 2012 at 12:24 AM
You could also just use i
instead of two vars.
Ex:
for(int i = 0; i < 5; i++) {
spellRingTextString[i] = gameData.spellList[i].spellName;
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613071441im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
For loop not working 1 Answer
For loop C#? 2 Answers
Using for as while. 3 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers