반응형

아래와 같이 ObservableCollection이 있다고 할때, 특정 Item만 찾아서 처리를 해야 할 경우

 

public struct PLU {
        
public int ID { get; set; }
        
public string name { get; set; }
        
public double price { get; set; }
        
public int quantity {get;set;}

}
public static ObservableCollection<PLU> PLUList = new ObservableCollection<PLU>();

 

PLU item = PLUList.Where(z => z.ID == 12).FirstOrDefault();

if (item != null)

{

//item이 있을 경우

}

else

{

//item이 존재하지 않을 경우

}

반응형

+ Recent posts