我有一个列表分配项目列表中,如果CONTAINS
public List<OrderLineItemQuestionPrice> QuestionPriceList { get; set; }
public class OrderLineItemQuestionPrice
{
public string DisplayName { get; set; }
public Price Price { get; set; }
public string QuestionCode { get; set; }
}
我还有一个列表
List<OrderLineItemQuestionPrice> promotionItem;
,我想的QuestionPriceList
项目分配给promotionItem
如果QuestionCode
包含“促销”。
List<OrderLineItemQuestionPrice> promotionItem = orderLineItemList.QuestionPriceList.Where(p=>p.QuestionCode.Contains("Promotion"))
可以添加OrderLineItemQuestionPrice的类定义? – Mohanraja
你需要一个AddRange:promotionItem.AddRange(QuestionPriceList); – jdweng