- Home /
How do I check for strings in an array to match up with the index of another array?
Okay so I'm trying to make an application that you can make tests in to make studying easier and I wanna be able to check if an array of strings that contains the answers match up with another array that has the correct answers. How do I do this?
Here's what I've got so far:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class TestMenu : MonoBehaviour
{
public List<Test> tests = new List<Test>();
public int questionsToAdd;
public string[] answerToQuestion;
public string[] answers;
void OnGUI ()
{
if(GUI.Button(new Rect(Screen.width/2 - 50,Screen.height/2,100,20), "Submit"))
{
}
}
void CorrectTest ()
{
for(int i = 0; i < tests.Count; i++)
{
}
}
}
Comment
Answer by gabriead · Dec 03, 2014 at 11:51 PM
You could use your for-loop to save the first value of the array "answerToQuestion" in a string (StringA) and then use a second for-loop to iterate through your array "answers" and compare every string in the array "answers" using StringA.Equals(StringB)
Your answer
![](https://koobas.hobune.stream/wayback/20220613173118im_/https://answers.unity.com/themes/thub/images/avi.jpg)