Looping through dictionary object

前端 未结 4 1773
悲哀的现实
悲哀的现实 2020-12-14 14:51

I am very new to .NET, used to working in PHP. I need to iterate via foreach through a dictionary of objects. My setup is an MVC4 app.

The Model looks l

4条回答
  •  余生分开走
    2020-12-14 15:33

    public class TestModels
    {
        public Dictionary sp = new Dictionary();
    
        public TestModels()
        {
            sp.Add(0, new {name="Test One", age=5});
            sp.Add(1, new {name="Test Two", age=7});
        }
    }
    

提交回复
热议问题