I am reading data from a text file.
The data is stored in text file as,
1,A
2,B
3,C
4,A
5,B
and so on…
following is the code that I am using…
string[] str = Correct_Ans.text.Split("\n".ToCharArray());
for (int i = 0; i < 10; i++) {
string[] qAns = str[i].Split(',');
if(qAns[1] == "A") {
GameConstants.AnswerArray[i+1] = 1;
}
else if(qAns[1] == "B")
GameConstants.AnswerArray[i+1] = 2;
else
GameConstants.AnswerArray[i+1] = 3;
Debug.Log("Ans Array = " + GameConstants.AnswerArray[i+1] );
Debug.Log("qAns[1] = " + qAns[1] + "Type = "+qAns[1].GetType());
}
The Debug stmt
Debug.Log("qAns[1] = " + qAns[1] + "Type = "+qAns[1].GetType());
gives proper output ie:
qAns[1] = C Type = System.String
but Debug.Log("Ans Array = " + GameConstants.AnswerArray[i+1] );
gives output as : Ans Array = 3
It always executes the else statement.
I have used all possible functions for comparing these two strings but still the output is same…
Please help.
Regards,
Amit.