C# foreach循环绑定key数组和value 数组(备用)

<div class="ContextualTab inner_warp clearfix"  data-max="2" data-blur=false data-split="1">

                                @if (!Model.CompanyType.IsNull() && !Model.CompanyTypeString.IsNull()) {

                                    var companyTypeString = Model.CompanyTypeString.Split(',').ToList();

                                    var companyType = Model.CompanyType.Split(',').ToList();

                                    foreach (var item in companyTypeString) {

                                        var index = companyTypeString.IndexOf(item);

                                        <span class="tags" data-id="@companyType[index]">@item<em>×</em></span>

                                    }

                                }

                                <input id="CompanyType" type="text" data-id="@Model.CompanyType" placeholder="添加行业标签,把握就业方向" />

                            </div>

环境:

key在一个数组里面,key对应的value在另一个数组里面

  

你可能感兴趣的:(foreach)