c# List集合的Find方法适用

时间:2023-01-17 15:25:28

CabinEntity为你定义的实体

CabinEntity existCabin = listCabins.Find(delegate(CabinEntity cabinE)
             {
                 return cabinE.AirCompany == modelPrice.AirCompany
                     && cabinE.Cabin == modelPrice.Cabin
                     && cabinE.ValidBeginTime <= modelPrice.TravelBeginTime && modelPrice.TravelBeginTime <= cabinE.ValidEndTime
                     && cabinE.ValidBeginTime <= modelPrice.TravelEndTime && modelPrice.TravelEndTime <= cabinE.ValidEndTime;
             });