我想分配屬性subdecision_typex_value,它是DtoReport類的一個屬性,使用新語句中的foreach循環。在新的語句中動態地分配一個屬性
這是可能的嗎?是否有意義 ?
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
}
爲什麼downvote?我不明白... –