In my quest to static-ify my code I have an Invalid Cast error which I can’t figure out.
The code is simple enough
for(x=0 ; x<textLine.Length ; x++)
{
if (q==0)
{
print("Question="+textLine[x]);
question=textLine[x];
}
else if (q<=numberOfCorrectAnswers)
{
print("Correct Answer="+textLine[x]);
correctAnswers[q-1]=textLine[x];
}
else
{
print("Wrong Answer="+textLine[x]);
wrongAnswers[(q-numberOfCorrectAnswers)-1]=textLine[x];
}
q++;
if (q>numberOfAnswersPerQuestion){q=0;}
}
and the error I get is InvalidCastException:Cannot cast from source type to destination type. The error points to the line question=textLine[x];
Note that question is defined earlier in the script as var question :String;
Any ideas?