Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在Asp.net MVC中为类创建对象_C# - Fatal编程技术网

C# 如何在Asp.net MVC中为类创建对象

C# 如何在Asp.net MVC中为类创建对象,c#,C#,我有课 public class TabMasterViewModel : ITabMasterModel { [ReadOnly(true)] public int colID { get; set; } [DisplayName("FirstName")] public string FirstName { get; set; } [DisplayName("LastName")] pu

我有课

 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; }
    }
现在我想从数据库中删除以下三条记录

 [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");
        }
[HttpPost]
公共行动结果移除选择(IList TabMasters)
{
IList TabMasters=new IList;//此行给了我一个错误。。
列出恐龙=新列表();
int[]colid={103410351036};
foreach(整数colid in colid)
{
//Add(新的TabMasterViewModel{colID=colID});
TabMasterViewModel tvm=新TabMasterViewModel{colID=colID};
TabMasters.Add(tvm);
//_tabmasterService.Delete(tvm);
}
_tabmasterService.DeleteList(TabMasters);
//返回视图(_tabmasterService.GetAll(x=>(x.colID==1034 | | x.colID==1035 | | x.colID==1036));
返回操作(“索引”);
}
但我不是亚伯,不适合写作

IList<TabMasterViewModel> TabMasters = new  IList<TabMasterViewModel>
IList TabMasters=新IList
IList TabMasters=new List();
IList是一个接口,无法实例化

IList TabMasters=new List();

IList是一个接口,无法实例化

回答得又好又快。谢谢你,伙计!回答得又好又快。谢谢你,伙计!
IList<TabMasterViewModel> TabMasters = new  List<TabMasterViewModel>();