1) Using Delegate to Check the item in the Generic list private bool CheckItemExistence(InspectionCheckList chkList)
{
List<InspectionCheckList> insChkList = new List<InspectionCheckList>();
insChkList = (List<InspectionCheckList>)Session[SessionVariable.CheckList];
if (insChkList != null)
{
if (insChkList.Exists(delegate (InspectionCheckList o) {return o.CodeID == chkList.CodeID;}))
return true;
else
return false;
}
else
return false;
}
2)Using Delegate to Find the Item in the Generic list then remove from the Generic list private void RemoveFromLIst(int itemId)
{
List<InspectionCheckList> insChkList = new List<InspectionCheckList>();
insChkList = (List<InspectionCheckList>)Session[SessionVariable.CheckList];
InspectionCheckList desiredObject =
insChkList.Find(delegate(InspectionCheckList o) { return o.CodeID == itemId; });
insChkList.Remove(desiredObject);
//grdSaveItems.DataSource = insChkList;
//grdSaveItems.DataBind();
Session[SessionVariable.CheckList] = insChkList;
}