我想在新语句中使用 foreach 循环分配属性 subdecision_typex_value ,它是 DtoReport 类的属性。
这可能吗?是否有意义 ?
public DtoReport Get(Report repResp)
return new DtoReport()
{
archivingId = repResp.archivingId.ToString(),
dateCreated = DateTime.Now,
//I'D LIKE TO DO IT THAT WAY IS IT POSSIBLE SOMEHOW ?
foreach(Subdecision d in repResp.decisionMatrix.subdecisions){
if(d.type == "SOME VALUE"){
//Dynamically assign DtoReport subdecision_typex_value Property
subdecision_typex_value = d.value
}
}
//END
anotherProperty = repResp.AnotherProperty
}