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>();
我有ObservableCollection,如上所示。现在我想搜索的ID在PLUList并获得它的索引是这样的:如何在Observable Collection中搜索项目并获取其索引
int index = PLUList.indexOf();
if (index > -1) {
// Do something here
}
else {
// Do sth else here..
}
什么是速战速决?
编辑:
让我们假设,一些项目被添加到PLUList,我想添加一个新的项目。但在添加之前,我想检查列表中是否存在该ID。如果确实如此,我想为数量添加+1。
我想只有搜索ID! – user995387 2012-02-17 12:57:34