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

mongodb - Struggling to get ordered results from the last retrieved article, given array of elements to search in -

c# - Pausing a storyboard on TabItem mouse over -

c# - Attribute value in root node of xml Linq to XML -