linq - How to update a property for a specific element of an IEnumerable List in C# -
i have ienumerable
list, ienumerable<sortelement>
sorts;
i updating property as:
sorts.where(a => a.displayname.tolower() == "abc") .tolist() .foreach(sl => sl.displayname = "testing");
but not change property specific element.
change "abc"
"abc"
. condition never met. can change .tolower()
.toupper()
.
i thing this:
foreach(var e in sorts.where(a => a.displayname.tolower() == "abc")) e.displayname = "testing";
because code in fact executes 2 loops, that's not necessary.
Comments
Post a Comment