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 like this:
public class TestModels
{
Dictionary<int, dynamic> sp = new Dictionary<int, dynamic>
{
{1, new {name="abc", age="1"}},
{2, new {name="def", age="2"}}
}
}
Controller:
public class TestController : Controller
{
Models.TestModels obj = new Models.TestModels();
}
How do I loop through the obj
object and retrieve the values of the dictionary and print them in the view?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…