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

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

c++ - Clear the memory after returning a vector in a function -

erlang - Saving a digraph to mnesia is hindered because of its side-effects -