我认为我需要使用一个 for 循环,这样我就可以访问数组中每一行中的每个属性来组成我的字符串。
public static string GetHintText(this IEnumerable<UserTrainingPointsDataModel> HintTextString)
{
foreach (var part in HintTextString)
{
HintText = HintText + " " + part.Name + " " + part.IncentiveTrainingModuleOptionName + " = " + part.Points;
}
return HintText;
}
public class UserTrainingPointsDataModel
{
public virtual int InteractionType { get; set; }
public virtual int Points { get; set; }
public virtual string Name { get; set; }
public virtual string IncentiveTrainingModuleOptionName { get; set; }
}
每行包含值:
China Incentive Program Points For Completing = 50
India - Q2 Incentive Points Per Correct Answer = 50
China - Q2 Incentive Points For Completing = 50
India Incentive Program Points Per Correct Answer = 100
India - Q2 Incentive Points Per Correct Answer = 100
HintTextString
包含 5 行,每行具有上述属性,我需要组成一个如下所示的字符串:
"Incentive Program: " + part.Name[0] + " " + part.IncentiveTrainingModuleOptionName[0] + " + " + part.Points[0] +
"Incentive Program: " + part.Name[1] + " " + part.IncentiveTrainingModuleOptionName[1] + " + " + part.Points[1]
等等,所以我需要一个 for 循环而不是?以及如何获得 HintTextString 的长度?智能感知没有给我那个属性
风景:
<% if (module.HasAssessment)
{ %>
<div class="<%: moduleStateClass %>"> </div>
<div class="<%: moduleScoreClass %>"><%: module.ModuleScore %></div>
<% var HintText = TrainingModuleProgressStateDataModelExtentions.GetHintText(module.UserTrainingPoints); %>
<script type="text/javascript">
<%: Html.GetQTip("training-module-id-" + module.TrainingModuleId , "Incentive program: " + HintText , "training-module-id-" + module.TrainingModuleId , Zinc.Web.Extensions.QTipPosition.Bottom, true, "Module Points") %>
</script>
<% } %>
<% else
{ %>
<% var HintText = TrainingModuleProgressStateDataModelExtentions.GetHintText(module.UserTrainingPoints); %>
<script type="text/javascript">
<%: Html.GetQTip("training-module-id-" + module.TrainingModuleId , "Incentive program: " + HintText ,"training-module-id-" + module.TrainingModuleId , Zinc.Web.Extensions.QTipPosition.Bottom, true, "Module Points") %>
</script>
<% } %>
“行动” :
<div class="module-column-content">
<% Html.RenderPartial("~/Areas/Training/Views/Home/Details.ascx", Model); %>
</div>
谢谢