private void SubMethod(object obj) { try { if ((string)obj == "Mashroom") { if (MashroomCount > 0) { MashroomCount--; MashroomsCustomNos.RemoveAt(MashroomsCustomNos.Count - 1); Foods.Remove(Foods.OfType <Caters.Model.Pizza.Mashroom>().First()); } } else if ((string)obj == "Panner") { if (PannerCount > 0) { PannerCount--; PannerCustomNos.RemoveAt(PannerCustomNos.Count - 1); Foods.Remove(Foods.OfType <Caters.Model.Pizza.PannerPizza>().First()); } } else if ((string)obj == "SevenUp") { if (SevenUpCount > 0) { SevenUpCount--; SevenUpCustomNos.RemoveAt(SevenUpCustomNos.Count - 1); Foods.Remove(Foods.OfType <Caters.Model.ColdDrink.SevenUp>().First()); } } } catch (Exception ex) { throw; } }