I use the following template in C #:
IList<foo> x = y.Select(a => new foo { b = Calc1(), c = Calc2() }).ToList(); foreach(foo f in x) { fd = b / c; }
What I would like to do is:
IList<foo> x = y.Select(a => new foo { b = Calc1(), c = Calc2() d = b / c; }).ToList();
So the question is: how can you modify this template to allow you to assign a value that depends on other values ββcalculated at the time of the assignment?
(Someone will probably indicate that d should be a property that evaluates and returns a value. This is a contrived example. Suppose that the value of d is computed using other values ββin addition to c and b, which are not available later.)
source share