0

I have class

 public class TabMasterViewModel : ITabMasterModel
    {
        [ReadOnly(true)]
        public int colID { get; set; }
        [DisplayName("FirstName")]
        public string FirstName { get; set; }
        [DisplayName("LastName")]
        public string LastName { get; set; }
    }

Now i want to delete following three records from database

 [HttpPost]
        public ActionResult RemoveSelected(IList<TabMasterViewModel> TabMasters)
        {
            IList<TabMasterViewModel> TabMasters = new  IList<TabMasterViewModel>;  //this line is giving me an ERROR..
            List<string> dinosaurs = new List<string>();

            int[] colIDs = { 1034, 1035, 1036 };
            foreach (int colid in colIDs)
            {
                //TabMasters.Add(new TabMasterViewModel { colID = colid });
                TabMasterViewModel tvm = new TabMasterViewModel { colID = colid };
                TabMasters.Add(tvm);
                //_tabmasterService.Delete(tvm);
            }
            _tabmasterService.DeleteList(TabMasters);
            //return View(_tabmasterService.GetAll(x => (x.colID == 1034 || x.colID == 1035 || x.colID == 1036)));
            return RedirectToAction("Index");
        }

but i am not abel to write proper for

IList<TabMasterViewModel> TabMasters = new  IList<TabMasterViewModel>

1 Answer 1

3
IList<TabMasterViewModel> TabMasters = new  List<TabMasterViewModel>();

IList<> is an interface and cannot be instantiated.

Sign up to request clarification or add additional context in comments.

1 Comment

Excellent and Quick answer. Thanks buddy!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.