I recently used this site to get code to extract an array of property values from a list of objects (I searched again and again and cannot find the original message or update help :()
This is the result:
qtyArray.AddRange(plan.Components.Select(c => c.qty.HasValue ? (int)c.qty.Value : 0).ToArray());
The problem is that I have other properties that I output to parallel arrays to go to the data source, but would prefer to ignore any false "active" properties. Therefore, for all arrays, do something like the above, but only where c.active == true:
plan.Components.Select(c => c.qty.HasValue ? (int)c.qty.Value : 0 **WHERE c.active**)
Can anyone help?
source
share