"shapper" <md*****@gmail.comwrote in message
news:49**********************************@1g2000pr e.googlegroups.com...
Hello,
I have a List<MyObjectwhere MyObject has two properties: N (int) and
Weight (int).
In this list only the N is defined for each tag.
I want to calculate the Weight for each MyObject in the list, as
follows:
Weight of MyObject = N of Tag / Maximum N of all MyObject in list
How can I do this using a Linq expression?
You don't. LINQ takes one sequence as input, and produces another new
sequence at the output. From your description, you want to mutate the values
in-place, and within the same List - in which case foreach is the best tool
for the job here (though you could still use Enumerable.Max() to calculate
the maximum N first).