if (cookieId != null)
{
AgencyModel model2 = AgencyLogic.Get(59);
string IsQuoShow = model2.IsMaster;
ModelCollection cuPMModel = ProductMenuLogic.GetProductByidr(IsQuoShow);
ModelCollection cQPMModel = new ModelCollection();
string isQShow = AgencyInfo.IsQuoShow;
for (int i = 0; i < cuPMModel.Count; i++)
{
string[] arrQs = isQShow.Split(',');
for (int j = 0; j < arrQs.Length; j++)
{
if (!string.IsNullOrEmpty(arrQs[j]) && cuPMModel[i].ProductMenuId == Convert.ToInt32(arrQs[j]))
{
cQPMModel.Add(cuPMModel[i]);
}
}
}
rptNews.DataSource = cQPMModel;
rptNews.DataBind();
}
代码如上,想要读出cQPMModel这个model里面的第一条数据,有大神有方法解决吗
你查找到第一条后直接break掉不就行了
for (int i = 0; i < cuPMModel.Count; i++)
{
string[] arrQs = isQShow.Split(',');
bool find=false;//////////////
for (int j = 0; j < arrQs.Length; j++)
{
if (!string.IsNullOrEmpty(arrQs[j]) && cuPMModel[i].ProductMenuId == Convert.ToInt32(arrQs[j]))
{
cQPMModel.Add(cuPMModel[i]);
find=true;break;//////////////
}
}
if(find)break;//////////////
}