how to check if List element contains an item with a Particular Property Value

前端 未结 6 884
野的像风
野的像风 2020-12-07 11:54
public class PricePublicModel
{
    public PricePublicModel() { }

    public int PriceGroupID { get; set; }
    public double Size { get; set; }
    public double S         


        
6条回答
  •  天涯浪人
    2020-12-07 12:31

    This is pretty easy to do using LINQ:

    var match = pricePublicList.FirstOrDefault(p => p.Size == 200);
    if (match == null)
    {
        // Element doesn't exist
    }
    

提交回复
热议问题