String.Equals returning false?

Hey, I see that someone asked something like that, but I think my problem is different.

So:

  1. I have a TextAsset named teste.
  2. the first line of this .txt file is “title”

And I have this function:

void updateText(){
	string[] lines = teste.text.Split('

');
foreach (string line in lines){
if (line.Equals(“title”)) {
//Do something
}
Debug.Log(line);
}
}

Even that Debug.Log is returning to me title, but that if statement is always returning false and I don’t understand why. Care to help?

You can try removing extra whitespace by using the Trim() function.

if (line.Trim().Equals("title")) {

If the length is different, this is almost certainly your issue. An extra space, newline, tab, etc.

You could try:

if (string.Compare(line, “title”) == 0)
//Do things