Using a linq or lambda expression in C# return a collection plus a single value
Posted
by ahsteele
on Stack Overflow
See other posts from Stack Overflow
or by ahsteele
Published on 2010-04-07T22:15:33Z
Indexed on
2010/04/07
22:43 UTC
Read the original article
Hit count: 200
I'd like to return a collection plus a single value. Presently I am using a field to create a new list adding a value to the list and then returning the result. Is there a way to do this with a linq or lambda expression?
private List<ChargeDetail> _chargeBreakdown
= new List<ChargeDetail>();
public ChargeDetail PrimaryChargeDetail { get; set; }
public List<ChargeDetail> ChargeBreakdown
{
get
{
List<ChargeDetail> result =
new List<ChargeDetail>(_chargeBreakdown);
result.Add(PrimaryChargeDetail);
return result;
}
}
© Stack Overflow or respective owner