我可以组合复杂和简单属性的属性顺序吗? e.g。
public class Car
{
public string Color {get;set;}
public string Engine {get;set;}
}
public class Report
{
public Car Car {get;set;}
public string Name {get;set;}
}
使用Display / EditorForModel查看我想要的顺序是:
颜色 名称 发动机
有可能吗?
感谢
答案 0 :(得分:0)
您可以在C#中使用匿名类型,请查看此示例: -
Car car = new Car { Color = "Red", Engine = "E1" };
Report report = new Report { Cars = car , Name = "Car1" };
var Result = new { Color = report.Cars.Color, Name = report.Name, Engine = report.Cars.Engine };