I have an if
in a foreach
and it returns true
only if the word I'm searching is the last one and I don't know what to do
public Text InputNrDeImt;
public Text status;
public string rbd;
public string[] bd;
public string path;
public string NrDeImt;
public void OnCheck(){
path = Application.persistentDataPath +"/BazaDeDate.txt";
StreamReader reader=new StreamReader(path);
rbd= reader.ReadToEnd();
reader.Close();
bd=rbd.Split("\n"[0]);
NrDeImt = InputNrDeImt.text.ToString();
foreach(string word in bd){
if(NrDeImt==word){
status.text= "found";
}
else{
status.text= "Nu este in baza";
}
}
}
the file looks like that
aaa
aab
aba #the word i was looking for
abb
baa
bab
bba
bbb
and my code only finds the word if it's "bbb"