Hi I have some problems with sequenceEqual when I have situation like this:
Sentence s1 = new Sentence { Text = "Hi", Order = 1 };
Sentence s2 = new Sentence { Text = "Hello", Order = 2 };
List<Sentence> list1 = new List<Sentence> { s1, s2 };
List<Sentence> list2 = new List<Sentence> { s1, s2 };
and this works fine
bool equal = list1.SequenceEqual(list2);
and returns true
;
but when I have some method which returns List<Sentence>
for example:
public List<Sentence> Getall()
{
Sentence s1 = new Sentence { Text = "Hi", Order = 1 };
Sentence s2 = new Sentence { Text = "Hello", Order = 2 };
return new List<Sentence> { s1, s2 };
}
and use it like this:
List<Sentence> list1 = Getall();
List<Sentence> list2 = Getall();
and then simply, check it
bool equal = list1.SequenceEqual(list2);
it returns 'false', please tell me why? and how to make it work?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…