The error isn't that
r.Num
and
r.Denum
are unknown; the error is that the division operator isn't defined for the anonymous types.
Change your code to:
var res = mytotal.Zip(GrantedReqStatus, (n, d) => new { Num = n.Total, Denum = d.GrantedCount });
foreach (var r in res)
{
GrantedAccessPercent.Add((double)r.Num / r.Denum);
}
Or, more simply:
var GrantedAccessPercent = mytotal.Zip(GrantedReqStatus, (n, d) => (double)n.Total / d.GrantedCount }).ToList();
NB: You need to cast either the numerator or the denominator to
double
before dividing, otherwise the result will be truncated.