我正在尝试将动态结果传递给View from Controller,方法ShowColor返回动态结果.在视图中我尝试循环收集,但我收到错误
'object'不包含'ColorID'的定义.
我在Controller和View中有以下代码
public class myColor
{
public int ID { get; set; }
public string Name { get; set; }
public string Like { get; set; }
}
public dynamic ShowColor()
{
IList<myColor> color = new List<myColor>();
color.Add(new myColor { ID = 1, Name = "Red", Like = "***" });
color.Add(new myColor { ID = 2, Name = "Green", Like = "*****" });
color.Add(new myColor { ID = 3, Name = "Blue", Like = "**" …Run Code Online (Sandbox Code Playgroud)