我正在尝试从我的模型中显示一个属性。目前我无法在顶部显示 2 人的地址?
动作方法
public ActionResult Index()
{
Person person = new Person() {name="Jan Kees",address="Beukenootjes straat 23" };
Person person2 = new Person() { name = "Peter Jan", address = "Beukenootjes straat 23" };
List<Person> lijst = new List<Person>();
lijst.Add(person);
lijst.Add(person2);
return View(lijst);
}
人类
public class Person
{
public string name { get; set; }
public string address { get; set; }
}
索引视图
@model IEnumerable<stack.Models.Person>
@item.address @*how to display address?*@
@foreach (var item in Model)
{
@item.name <br />
}