c# - Different objects but same value? -
this question has answer here:
i have problem when tried change of value.
list<reflanguage> languages1 = _reflanguageservice.getall(); list<reflanguage> languages2 = languages1; languages1.where(x => x.id == 1).tolist().foreach(x => x.name = "turkish"); boolean issame = languages1.equals(languages2);
the first line getting reflanguage records using ef.
when execute code, value of issame object true.
the line list<reflanguage> languages2 = languages1;
points reference of languages1
same memory languages2
. .equals
method compare 2 references, in case same.
what instead can compare is
bool issame = languages1.sequenceequal(languages2);
Comments
Post a Comment